Hello Everyone,
I am a newbie to VB and I am trying to Insert/Delete records in a MSSQL database based on if a checkbox is checked or unchecked. The checkbox is an item template in a datagrid, I can check/uncheck the checkbox but it doesn't do an insert or delete. Here is my code:
ASPX Page:
.VB Page:HTML Code:<asp:TemplateColumn><ItemTemplate><asp:CheckBox runat="server" ID="chkMap" OnCheckedChanged="chkmap_CheckChanged" AutoPostBack="true"></asp:CheckBox></ItemTemplate></asp:TemplateColumn>
I even tried to erasing all the code & doing something along these lines in the code behind:Code:Private Sub chkmap_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim Data As New Stored.BusinessLogicLayer.CInput.DataInput Dim Deletion As New Stored.BusinessLogicLayer.CInput.DataRemoval Dim ceId As Integer = CInt(Session("ceid")) Dim userId As Integer = CInt(Session("userid")) Dim manchestStore As Integer = CInt(Session("mancheststore")) Dim compId As Integer Dim uComp As Integer Dim assignCount As Integer = 0 Dim i As Integer For i = 0 To dgCStores.Items.Count - 1 If CType(dgCStores.Items(i).Cells(0).FindControl("chkMap"), CheckBox).Checked = True Then compId = CInt(dgCStores.Items(i).Cells(1).Text) uComp = CInt(dgCStores.Items(i).Cells(3).Text) Data.InputUserMap(userId, ceId, uComp, manchestStore) assignCount += 1 ElseIf CType(dgCStores.Items(i).Cells(0).FindControl("chkMap"), CheckBox).Checked = False Then compId = CInt(dgCStores.Items(i).Cells(1).Text) uComp = CInt(dgCStores.Items(i).Cells(3).Text) Deletion.DeleteUserMapping(userId, ceId, uComp, manchestStore) End If Next End Sub
But then I get the error that the control chkmap has not been declared. I am confused as to how this needs to be declared, do I set a variable to the FindControl("chkmap") and then set it as variable.checked = true ?Code:Private Sub chkmap_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim Data As New Stored.BusinessLogicLayer.CInput.DataInput Dim Deletion As New Stored.BusinessLogicLayer.CInput.DataRemoval Dim ceId As Integer = CInt(Session("ceid")) Dim userId As Integer = CInt(Session("userid")) Dim manchestStore As Integer = CInt(Session("mancheststore")) Dim compId As Integer Dim uComp As Integer If chkmap.Checked = True Then Data.InputUserMap(userId, ceId, uComp, manchestStore) Else Deletion.DeleteUserMapping(userId, ceId, uComp, manchestStore)
Hope you guys can help me out
Thanks


Reply With Quote




