This is a migrated thread and some comments may be shown as answers.

find check changed event if true or false

2 Answers 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 19 Jul 2012, 01:07 PM
HI,

Ok, with some help i got to this point but found out on postback for some reason it alwyas registers my check event as as false and then i get an error in the datasource event, how can I check for it the cb_checkchanged event is true or false for checked or not in the event so that I can set the value of my hidden field to load the grid properly.

Protected Sub myRadGrid_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles myRadGrid.ItemCreated
      If TypeOf e.Item Is GridCommandItem Then
          Dim citem As GridCommandItem = DirectCast(e.Item, GridCommandItem)
          Dim Cb As CheckBox = DirectCast(citem.FindControl("cbhist"), CheckBox)
          If Cb.Checked = True Then
              HFHist.Value = 1
              AddHandler Cb.CheckedChanged, AddressOf cb_CheckedChanged
          Else
              HFHist.Value = Nothing
              AddHandler Cb.CheckedChanged, AddressOf cb_CheckedChanged
          End If
      End If
  End Sub
  Private Sub cb_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
      myRadGrid.Rebind()
  End Sub

Protected Sub myRadGrid_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles myRadGrid.NeedDataSource
      Dim sqlwhere As String
      If Int32.Parse(HFHist.Value) = 1 Then
          sqlwhere = ""
      Else
          sqlwhere = "where bitJ6 IS NULL or bitJ6 = 0"
      End If
      sql = "Select f.intFlagId, f.intPersonnelid, mn.strFullname + ' ' + mn.strRank Flag, m.strFullname + ' ' + m.strRank FlagBy, CONVERT(varchar(10), dtFlagged, 101) dtFlagged, bitUnit, bitJ2, bitJ6, strNotes " _
          & "from iMAC_J2Flag f INNER JOIN MnNgPersonnel.dbo.tblMNNatPersonnel mn on mn.intPersonnelId = f.intPersonnelId INNER JOIN MnNgPersonnel.dbo.tblMNNatPersonnel m on m.intPersonnelId = f.intFlagBy " _
          & "" & sqlwhere & ""
      Response.Write(sql)
      Response.End()
      myRadGrid.DataSource = getData(sql)
  End Sub

2 Answers, 1 is accepted

Sort by
0
Elliott
Top achievements
Rank 2
answered on 19 Jul 2012, 04:33 PM
I would check to see if your ajax manager is correctly coded
my guess, and it is just that, is that your checkbox is not being sent back to the server
0
Radoslav
Telerik team
answered on 24 Jul 2012, 09:07 AM
Hi Marianne,

Could you please try modifying the code snippet as following and let me know if it helps you:
Protected Sub myRadGrid_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles myRadGrid.ItemCreated
      If TypeOf e.Item Is GridCommandItem Then
          Dim citem As GridCommandItem = DirectCast(e.Item, GridCommandItem)
          Dim Cb As CheckBox = DirectCast(citem.FindControl("cbhist"), CheckBox)
          
          AddHandler Cb.CheckedChanged, AddressOf cb_CheckedChanged
           
      End If
  End Sub
 
    Private Sub cb_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
        Dim Dim Cb As CheckBox = DirectCast(sender, CheckBox)
        If Cb.Checked = True Then
              HFHist.Value = 1
          Else
              HFHist.Value = Nothing
          End If
      myRadGrid.Rebind()
  End Sub

Looking forward for your reply.

Kind regards,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Elliott
Top achievements
Rank 2
Radoslav
Telerik team
Share this question
or