HelloBD
HelloBD

Reputation: 387

Gridview SelectedIndex value set

Work on Asp.Net C# .

<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="CategoryID"
                                DataSourceID="SqlDataSource1" OnSelectedIndexChanged="GridView2_SelectedIndexChanged" OnRowCommand="GridView2_RowCommand">
                                <Columns>
                                    <asp:CommandField ShowSelectButton="True" />
                                    <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" InsertVisible="False"
                                        ReadOnly="True" SortExpression="CategoryID" />
                                    <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" />
                                    <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                                </Columns>
                            </asp:GridView>

protected void GridView2_SelectedIndexChanged(object sender, EventArgs e) {

   GridView2.FindControl("CategoryID").Text=2;

}

want selected column value change on ridView2_SelectedIndexChanged method .How to do ?

Upvotes: 1

Views: 2515

Answers (1)

Gregoire
Gregoire

Reputation: 24832

You can access to your selected row cells content by GridView2.SelectedRow.Cells[1].Text

Upvotes: 1

Related Questions