Select entire row details on click of button of that row inside a GridView
-
:zzz: I am displaying a GridView on some specific criteria which is entered by some textboxes say studentid, studentname as input from textbox and show records in GridView. For this I m using a stored procedure which returns a datatable based on inputs came from textboxes. I want an Edit button in the Gridview on click of which a
with some label and textbox controls get displayed with prefilled entries. For this I want the datarow from the datatable got from the stored procedure, from where I will get the complete info. Also I want to edit the data. How can I get the row details of specified Edit button row and which way is better put a command button control in ItemTemplate of GridView or use a Buttonfield cotnrol inside the GridView? I am working in ASP.NET2.0 and C#. I m not getting the correct way, can anybody suggest me? Thanks in advance,
-
:zzz: I am displaying a GridView on some specific criteria which is entered by some textboxes say studentid, studentname as input from textbox and show records in GridView. For this I m using a stored procedure which returns a datatable based on inputs came from textboxes. I want an Edit button in the Gridview on click of which a
with some label and textbox controls get displayed with prefilled entries. For this I want the datarow from the datatable got from the stored procedure, from where I will get the complete info. Also I want to edit the data. How can I get the row details of specified Edit button row and which way is better put a command button control in ItemTemplate of GridView or use a Buttonfield cotnrol inside the GridView? I am working in ASP.NET2.0 and C#. I m not getting the correct way, can anybody suggest me? Thanks in advance,
You can edit a particular datagrid row using EditCommand event of the datagrid. i attach code below: private void Edit_DataGrid(object source,System.Web.UI.WebControls.DataGridCommandEventArgs e) { // We use CommandEventArgs e to get the row which is being clicked // This also changes the DataGrid labels into Textboxes so user can edit them myDataGrid.EditItemIndex = e.Item.ItemIndex; // Always bind the data so the datagrid can be displayed. } thankyou Rasma
-
:zzz: I am displaying a GridView on some specific criteria which is entered by some textboxes say studentid, studentname as input from textbox and show records in GridView. For this I m using a stored procedure which returns a datatable based on inputs came from textboxes. I want an Edit button in the Gridview on click of which a
with some label and textbox controls get displayed with prefilled entries. For this I want the datarow from the datatable got from the stored procedure, from where I will get the complete info. Also I want to edit the data. How can I get the row details of specified Edit button row and which way is better put a command button control in ItemTemplate of GridView or use a Buttonfield cotnrol inside the GridView? I am working in ASP.NET2.0 and C#. I m not getting the correct way, can anybody suggest me? Thanks in advance,
To use RowDataBound to find Id in each row: In code behind: protected void Page_Load(object sender, EventArgs e) { //Accepting the Id of a clicked row. string id = Convert.ToString(Request.QueryString["id"]); } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string id = e.Row.Cells[0].Text.ToString(); e.Row.Attributes["onclick"] = "window.navigate('samewebpage.aspx?id=" + id + ")"; } } you can access id from page load, reading the entire data of corresponding id using datatable or datareader and display the contents in a textbox or label. Thankyou, Rasma