i need to set that if checkbox is not selected in repeater then set its default as 0 (zero)while insertion
let me have soem code stuff
please conside hotelbooking as insert clause where Convert.ToInt32(singlecheck.Checked) and Convert.ToInt32(doublecheck.Checked) need to set if not checked otherwise it take nullCode:For Each dataItem As RepeaterItem In Repeater1.Items Dim ckchecked As CheckBox = DirectCast(dataItem.FindControl("chk_packages"), CheckBox) ' Dim chk_single As CheckBox If ckchecked.Checked Then bb = 0 Dim chk_single As CheckBox = DirectCast(dataItem.FindControl("single"), CheckBox) Dim chk_double As CheckBox = DirectCast(dataItem.FindControl("double"), CheckBox) Dim txt_sing As TextBox = DirectCast(dataItem.FindControl("txt_single"), TextBox) Dim txt_doub As TextBox = DirectCast(dataItem.FindControl("txt_double"), TextBox) Dim j As Integer If (chk_single.Checked And txt_sing.Text = "") Then bb = 0 ElseIf (chk_double.Checked And txt_doub.Text = "") Then bb = 0 ElseIf chk_single.Checked And txt_sing.Text <> "" Then bb = 1 ElseIf chk_double.Checked And txt_doub.Text <> "" Then bb = 1 End If If bb = 0 Then lbl_error_package.Visible = True lbl_error_package.Text = "please select at least one package with either Number of rooms(single/double)" Exit For Else ' validate_form = True Dim str221 As String = userid & " " & ckchecked.Text & " " & DirectCast(dataItem.FindControl("single"), CheckBox).Checked.ToString() & " " & DirectCast(dataItem.FindControl("txt_single"), TextBox).Text & " " & DirectCast(dataItem.FindControl("double"), CheckBox).Checked.ToString() & " " & DirectCast(dataItem.FindControl("txt_double"), TextBox).Text attend_cmd = Nothing Dim singlecheck As CheckBox = DirectCast(dataItem.FindControl("single"), CheckBox) Dim doublecheck As CheckBox = DirectCast(dataItem.FindControl("double"), CheckBox) Dim no_single_room As TextBox = DirectCast(dataItem.FindControl("txt_single"), TextBox) Dim no_double_room As TextBox = DirectCast(dataItem.FindControl("txt_double"), TextBox) Dim hotel_book As String = "insert into hotelbooking (Userid, hotel_requirement_Types, singleroom, single_no_room,doubleroom,double_no_room) " & _ "VALUES (" & userid & ", '" & ckchecked.Text & "' , " & Convert.ToInt32(singlecheck.Checked) & " ," & Int32.Parse(no_single_room.Text) & "," & Convert.ToInt32(doublecheck.Checked) & "," & Int32.Parse(no_double_room.Text) & " )" attend_cmd = New SqlCommand(hotel_book, con) attend_cmd.ExecuteNonQuery() lbl_error_package.Visible = False End If End If Next 'for each


Reply With Quote
