I want a row in an ASP.NET GridView
to be selected with specified value for SelectedValue
.
The DataKeyNames
in GridView
is SN
, and I have something like this: mySN = 5;
I want to find the row in GridView
its value is equal to mySN
with C#
code.
Try this:-
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="id" onselectedindexchanged="GridView1_SelectedIndexChanged">
code behind:-
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
int index = Convert.ToInt16(GridView1.SelectedDataKey.Value);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.