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


Top 5 Contributors of the Month
david stephan

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
Hi,Experts

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
Dhilip.R

Responses
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" >
<Columns>
<asp:ButtonField Text="select" />
</Columns>
<SelectedRowStyle BorderColor="Blue" BorderStyle="Solid" />
</asp:GridView>

<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
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

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