How to select the Gridview rows data in asp.net ?


GrdSelect

Hi

It is very simple to do this functionality in asp.net

Step 1: Add the AutoGeneratedSelectButton=”true” in gridview like this

  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            AutoGenerateSelectButton="True"  
            DataSourceID="SqlDataSource1" 
            onselectedindexchanged="GridView1_SelectedIndexChanged1">

Step 2: Fire the event “SelectedIndexChanged” and write the code for selecting rows


protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e)
    {
        string actualWt = GridView1.SelectedRow.Cells[2].Text;
        string amount = GridView1.SelectedRow.Cells[3].Text;
    }

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.