Get the value from GridView Column without ViewState Enabled
Posted by
Manas
at
8:08:00 PM
Reactions:
Its easy to get value from the GridView column when ViewState is Enabled by using GridVIew_ItemCommand() event. But its little difficult to get the column value when the ViewState is Disabled. Here I found one solution for that and wish to share it here.
First you have to make the EnableViewState=False of the GridView control and then write following code line in GridView Design code
OnSelectedIndexChanged="radGridQcDupsView_SelectionIndexChanged"
Note: Here my GridView name is radGridQcDupsView. You change according to your GridView name.
Then in codebehind file(.cs/.vb) you can write following code according to your language
C#:
protected void grdQcDupsView _SelectionIndexChanged(object sender, EventArgs e)
{
string contentId = grdQcDupsView.DataKeyNames.GetValue(1).ToString();
long RowValue = long.Parse(contentId);
}
VB:
Protected Sub grdQcDupsView_SelectionIndexChanged(ByVal source As Object, ByVal e As EventArgs) Handles grdQcDupsView.SelectedIndexChanged
Dim contentId As String = grdQcDupsView.DataKeyNames.GetValue(1).ToString()
Dim RowValue As Long = CLng(contentId)
End Sub
Hope it Helps!
Labels: ASP.net GridView
Subscribe to:
Post Comments (Atom)



0 comments:
Post a Comment