gridview checkbox selection [Resolved]

Posted by hareeshkumarkr-16190 under ASP.NET on 8/16/2012 | Points: 10 | Views : 1118 | Status : [Member] | Replies : 2
hi

I have a gridview and inside the gridview I have a checkbox and after clicking the checkbox i want to read the slno
so how to write the code for this in GridView1_RowCommand..



thanking you in advance.......




Responses

Posted by: hareeshkumarkr-16190 on: 8/16/2012 [Member] Starter | Points: 25

Up
0
Down

Resolved
thank you very much


i got answer like

Protected Sub chkval_checkedchage(ByVal sender As Object, ByVal e As System.EventArgs)
Dim Check1 As CheckBox = DirectCast(sender, CheckBox)
Dim row As GridViewRow = DirectCast(Check1.NamingContainer, GridViewRow)
Dim lbl As Label = DirectCast(row.FindControl("LblCid"), Label)
Dim slct As New List(Of Integer)()

Dim cid As String = lbl.Text
If Check1.Checked = True Then
Label2.Text += cid & "<br>" & "<br>"
End If


End Sub

hareeshkumarkr-16190, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 8/16/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Try this to find control on GridView RowCommand Event

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
Control ctrl = e.CommandSource as Control;
if (ctrl != null)
{
GridViewRow gvRow = ctrl.Parent.NamingContainer as GridViewRow;
Label slno = (Label)gvRow.FindControl("slno"); // Find Control here
// Your work start here
}
}


hareeshkumarkr-16190, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response