Recent Posts

Posts RSS

Get the value from GridView Column without ViewState Enabled


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


 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

protected void grdQcDupsView _SelectionIndexChanged(object sender, EventArgs e)
string contentId = grdQcDupsView.DataKeyNames.GetValue(1).ToString();
long RowValue = long.Parse(contentId);

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!

kick it on