.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Forum >> .NET Framework >> Post New QuestionBookmark and Share Subscribe to Forum

Gridview Row Click and Updation

Posted By: Dhilip.R     Posted Date: November 26, 2010    Points:2   Category :.NET Framework

I need code for clicking the row in grid view and it'll show the details in text box and some other controls for updating the row.

Thanks & Regards

Author: SureshM          Accepted Answer   
Posted Date: November 27, 2010     Points: 10   

Use button field column, and onrowcommand event:

use the following Code:

In aspx:
<asp:GridView ID="gvtest" runat="server" onrowcommand="gvtest_RowCommand" >
<asp:ButtonField Text="select" />
<SelectedRowStyle BorderColor="Blue" BorderStyle="Solid" />

<asp:TextBox ID="txtval" runat="server" ></asp:TextBox>

in code behind:

protected void gvtest_RowCommand(object sender, GridViewCommandEventArgs e)
int index=Convert.ToInt32(e.CommandArgument);

GridViewRow gv = ((GridView)e.CommandSource).Rows[index];
txtval.Text = gv.Cells[1].Text;

this will help u...

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend