Dim i As Integer
Dim str1 As String
Dim t As HtmlInputCheckBox
str1 = ""
For i = 0 To GridView1.Rows.Count - 1
t = GridView1.Rows(i).Cells(6).FindControl("Checkbox1")
If t.Checked Then
If str1 = "" Then
str1 = t.Value
Else
str1 = str1 & "," & t.Value
End If
End If
Next
Label1.Text = str1
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [OrderID], [ProductID], [UnitPrice], [Quantity], [Discount] FROM [Order Details] WHERE ([ProductID] = @ProductID)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="ProductID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2"
DataTextField="ProductName" DataValueField="ProductID">
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataKeyNames="OrderID,ProductID" DataSourceID="SqlDataSource1" EmptyDataText="111">
<Columns>
<asp:BoundField DataField="OrderID" HeaderText="OrderID" ReadOnly="True" SortExpression="OrderID" />
<asp:BoundField DataField="ProductID" HeaderText="ProductID" ReadOnly="True" SortExpression="ProductID" />
<asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" DataFormatString="{0:C}" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" />
<asp:BoundField DataField="Discount" HeaderText="Discount" SortExpression="Discount" />
<asp:ImageField DataImageUrlField="OrderID" DataImageUrlFormatString="/{0}.gif" HeaderText="pic">
</asp:ImageField>
<asp:TemplateField FooterText="id">
<ItemTemplate>
<input id="Checkbox1" runat="server" type="checkbox" value='<%# Eval("OrderID") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<%=gridview1.PageIndex +1%>of<%=GridView1.PageCount%>
<br />
</div>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [ProductID], [ProductName] FROM [Products]"></asp:SqlDataSource>
</form>
</body>