I need the ability to check a box and then store or remove the text of the checkbox clicked to my sql server database. Please see my code below that is written in vb.
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="SBN_Company_Cat_Types.aspx.vb" Inherits="ShopBuyName_Test_Site.SBN_Company_Cat_Types" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div style=" clear:both; float: right">
<a href="javascript:history.go(-1)">Go Back</a>
</div>
<div style="background-color: #DFDFDF; border-style: double">
<asp:Label ID="lblCategory" runat="server" Text="Select a Category Type(s)" Font-Bold="true" ForeColor="Blue" Font-Names="Ariel"></asp:Label>
</div>
<br />
<asp:ListView ID="lvwSearchCategory" runat="server" GroupItemCount="5" DataSourceID="sdsrcSearchCategory">
<LayoutTemplate>
<div id="Div1" runat="server">
<div runat="server" id="groupPlaceholder">
</div>
</div>
<div style="clear: both;">
<asp:DataPager ID="ItemDataPager" runat="server" PageSize="90" >
<Fields>
</Fields>
</asp:DataPager>
</div>
</LayoutTemplate>
<GroupTemplate>
<div id="Div2" runat="server" style="margin: 3px; float: left;">
<asp:PlaceHolder runat="server" ID="itemPlaceholder" />
</div>
</GroupTemplate>
<ItemTemplate>
<div id="Div3" runat="server" style="width:125px; height:35px">
<asp:CheckBox ID="ckbxCatType" runat="server" AutoPostBack="true" Text='<%#Eval("ClassificationCategory")%>' Width="150" OnCheckedChanged="ckbxCatType_Click" />
<br />
</div>
</ItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="sdsrcSearchCategory" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" SelectCommand="aspnet_Select_Search_Categories"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter Name="TYPE" DefaultValue='CCTP' />
<asp:QueryStringParameter Name="CatType" QueryStringField="CatType" />
</SelectParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
VB
Protected Sub ckbxCatType_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim chk As CheckBox = CType(lvwSearchCategory.FindControl("ckbxCatType"), CheckBox)
MsgBox(chk.Text)
End Sub