gridview row selection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • meydanshahi
    New Member
    • May 2010
    • 5

    gridview row selection

    how can we select a row of a gridview and pass the values of this row to textbox.
    please reply me with c#.net codes not html codes.
    thanks a lot
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    The easiest way to do this is to add a CommandField column to the GridView with a "selection" button in it.

    Quick not working example:
    Code:
    <asp:GridView id="someGrid" runat="server">
      <Columns>
       <asp:CommandField ShowSelectButton="true" />
     </Columns>
    </asp:GridView>
    Then you would handle the GridView.Select edIndexChanged Event. This event is passed a parameter "e" that is a GridViewSelectE ventArgs type. This contains information about the row that was selected so that you can reference it in your C# code. Once you have a reference to the row you can use the row's FindControl() method to retrieve any controls in the row...or you can access the individual cells.

    -Frinny

    Comment

    Working...