Launch a fresh window showcasing specific information from a chosen row ID within a datagrid

I am working on a project where I need to display a gridview containing information about all the employees. When a user selects a particular employee, I want to open a new page or window that shows all the details of that employee with options for editing, deleting, and updating. After completing the transaction, the user should be able to return to the previous page with the gridview displaying all employees. (I am using VB language)

<asp:TemplateField Visible="true" headertext="Select"> 
            <ItemTemplate> 
              <asp:HiddenField ID="hdID01" runat="server" Value='<%# Eval ("PersonnelID") %>' />                 
            </ItemTemplate>                 
            <ItemTemplate> 
              <asp:LinkButton ID="lnkSelect" runat="server" CommandName="select"   Text="Select"  /> 
            </ItemTemplate> 
       </asp:TemplateField>

------ code behind ----

Protected Overridable Sub Grid_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
    If e.Row.RowType = DataControlRowType.DataRow Then
        ' Click to highlight row 
        Dim lnkSelect As Control = e.Row.FindControl("lnkSelect")
        If lnkSelect IsNot Nothing Then
            Dim click As New StringBuilder()
            click.AppendLine(GridView1.Page.ClientScript.GetPostBackClientHyperlink(lnkSelect, String.Empty))
            click.AppendLine(String.Format("onGridViewRowSelected('{0}')", e.Row.RowIndex))
            e.Row.Attributes.Add("onclick", click.ToString())
        End If
    End If
End Sub

------ Javascript -----

<script type="text/javascript">

    var selectedRowIndex = null;

    function onGridViewRowSelected(rowIndex) {
        selectedRowIndex = rowIndex;
    }

    function editItem() {
        if (selectedRowIndex == null) return;


        var cell = gridView.rows[parseInt(selectedRowIndex) + 1].cells[0];
        var hidID = cell.childNodes[0];
        window.open('mg_edit.aspx?id=' + hidID.value);
    } 

When I select an item, nothing happens. I'm stuck and need some assistance!

Answer №1

Check out these resources to help guide you in the right direction with implementing a GridView:

http://www.codeproject.com/KB/webforms/GridViewConfirmDelete.aspx http://weblogs.asp.net/scottgu/archive/2006/01/02/434362.aspx

If you're working with 3.5 or newer versions, you might also want to explore using a ListView control:

Best of luck on your project!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Experiencing a mysterious error in Vuex with undefined values while using a getter in a computed property

I've encountered an issue on my Vue.js website where the data is rendering correctly, but I keep receiving an undefined error in the console. The error seems to be related to an axios call I'm making in App.vue to fetch data from my CMS: In App. ...

Having issues when dynamically adding options to a multiselect dropdown

I'm working on dynamically adding options to a multiselect using AJAX: <select size='2' name="CraftCode" id=@ccrf class="form-control js-select manualentrydd" ></select> $.ajax({ type: "GET", url: "GetCraftCodes", data: ...

Find the variance between today's date and a selected date, then initiate the timer based on this variance

I have a grid containing data. I utilize the loadGrid() function to preload data or conditions before the grid finishes loading. When the active state is set to 1, my intention is to initiate a timer by calculating the difference between the current date ...

The mystery of d3.js and its absence in Meteor

I've been working with Meteor for a while and have experience with d3, but I'm struggling to make them work together! So far, I've attempted: meteor add d3js:d3, which results in: d3 is not defined <script src="http://d3js.org/d3.v3 ...

Keep the footer at the bottom of the screen without needing to define a 100vh in Material UI

In the process of developing my react app with MUI framework, I encountered various challenges in creating a sticky footer at the bottom of my screen. After exploring different solutions, one approach that I found most satisfactory is as follows: export de ...

Transmit information to Vue.js component

I am encountering an issue while attempting to transfer data from one component to another. Can someone provide assistance? Below is the code snippet: <template> <div class="q-pa-md" style="max-width: 900px"> <div v-if="fields.length" ...

Node server quickly sends a response to an asynchronous client request

Apologies for my lack of writing skills when I first wake up, let me make some revisions. I am utilizing expressjs with passportjs (local strategy) to handle my server and connect-busboy for file uploads. I believe passport will not have a role in this pr ...

Dynamic styles object for React components with inline styles

I have a styles object let styles = { step_div:{ height:'150px', } } I'm trying to display multiple div elements with different colors using React class Layout extends React.Component{ constructor(props) { super(props); ...

How to add a design to an image using a fabric pattern on a shirt

https://i.stack.imgur.com/ocWBp.png If I have an image and want to fill it with fabric below. And the final image will look like this: https://i.stack.imgur.com/vVv0I.png I just want to fill a pattern in a shirt like shown in this demo. Is there ...

Injecting styles dynamically with Nuxt: A step-by-step guide

During the development of a Nuxt application integrated with WordPress, I encountered an issue while trying to import custom CSS from the WordPress API. I am seeking guidance on how to incorporate custom CSS into a template effectively? <template> ...

Vue.js custom confirmation component failing to open within v-menu

I am having trouble displaying a confirmation component every time a button in the header is clicked. Currently, it only opens when clicking elements outside of the dropdown using v-menu. App.vue <template> {{isConfirmDialogVisible}} <div cla ...

What are some well-reputed JavaScript grids that can be populated with data using AJAX requests?

Looking for a grid that can be dynamically updated with ajax requests. The ability to sort, filter, and select items is essential. Your help is greatly appreciated! ...

I am looking to update the 'startbutton.href' value based on the dynamic change in 'img.src'. Unfortunately, the if-else statement has proven ineffective in achieving this

let index = 1; let images = [ './img/wok.jpg', './img/croissant.jpg', './img/salad.jpg' ]; let img = document.getElementById("section-1-img"); let startButton = document.getElementById('startButton& ...

What sets apart simple value state from object state in React?

Are there any distinctions between organizing component state as a single object bundle like this (1) const [state, setState] = useState({ title: 'Jerome Is Coming!', year: '1998' }) versus managing separate states with primitive ...

Why ASP.NET MVC Controllers are receiving null values when Javascript arrays are passed?

I've encountered an issue with passing a JavaScript array to the controller. In my View, I have multiple checkboxes that, when checked, trigger the saving of their ID to an array. This array needs to be utilized in the controller. Below is the code sn ...

Sending a `refresh` to a Context

I'm struggling to pass a refetch function from a useQuery() hook into a context in order to call it within the context. I've been facing issues with type mismatches, and sometimes the app crashes with an error saying that refetch() is not a funct ...

Vue users are experiencing issues with the functionality of the Chart js plugin annotation

I've been attempting to include a horizontal line in my Chart.js using the annotations plugin, but it's not cooperating. My Chart.js version is 2.9.4, so I had to install it with the command: npm install [email protected] --save After inst ...

What is the process for adding content to a textarea field?

Is there a way to dynamically update a textarea using PHP and trigger the refresh of the textarea? APPRECIATE IT Edit: The solution should be initiated by server-side PHP code ...

Why isn't the field I added to my state functioning properly?

Can anyone explain why I am getting names without the added selected field??? I can fetch names from my API JSON (1) and I'm attempting to modify it by adding the selected field (2). export default function Display() { ... const init ...

React - Refreshing a component with the help of another component

I've created a NavBar component that contains a list of links generated dynamically. These links are fetched from the backend based on specific categories and are stored within a child component of NavBar named DrawerMenu. The NavBar itself is a chil ...