Ancient piece of code that I keep forgetting.
<asp:GridView ID="grdR" runat="server" AutoGenerateColumns="False"
DataKeyNames="Id" style="margin-left: 6px; font-size: x-small;" Font-Size="Small">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField SelectText="Edit" ShowSelectButton="True" />
<asp:BoundField DataField="Length" HeaderText="Length" />
<asp:BoundField DataField="Breadth" HeaderText="Breadth" />
</Columns>
<EmptyDataTemplate>
There is no Value
</EmptyDataTemplate>
</asp:GridView>
Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click
Dim i As Integer
' Dim bidlist(grdR.Rows.Count) As Integer
For i = 0 To grdR.Rows.Count - 1
Dim cbgrd As CheckBox = CType(grdR.Rows(i).FindControl("CheckBox1"), CheckBox)
If (cbgrd.Checked) Then
Dim rowId As Integer = grdR.DataKeys(grdR.Rows(i).DataItemIndex).Value
' do what you want
End If
Next
Comments
Post a Comment