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

Check a Checkbox in a TemplateColumn inside a RadGrid with VB.NET

1 Answer 235 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 05 Jun 2014, 09:26 PM
I am having trouble checking a checkbox with VB.NET and RadGrid. So far I have been able to confirm that the value is indeed 1, but when I go to have the program check the box, it doesn't show anything.

My VB.NET code looks like this:

Protected Sub myRadGrid_RowDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles myRadGrid.ItemDataBound

            If e.Item.ItemType = DataControlRowType.DataRow Then
                If (System.Web.UI.DataBinder.Eval(e.Item.DataItem, "InLocation")) Then
                    Dim myinLocation As CheckBox = CType(e.Item.FindControl("cbLocationUsed"), CheckBox)
                    myinLocation.Checked = True
                    Dim myinLocation2 As CheckBox = CType(myRadGrid.MasterTableView.FindControl("cbLocationUsed"), CheckBox)
                    myinLocation2.Checked = True
                    myinLocation.DataBind()
                    myinLocation2.DataBind()
                    LoadMyRadGrid()
                End If
            End If

End Sub

What this should be doing, I think think, is taking in the row like a GridView would with RowDataBound and then check its type, evaluate the InLocation field and populate the checkbox if need be. I think threw a few different methods to see if they would solve it. Nothing really happened though. Which one of the methods would I use here? Or am I completely off track.

1 Answer, 1 is accepted

Sort by
0
Alexander
Top achievements
Rank 1
answered on 05 Jun 2014, 10:03 PM
I solved it just now. Instead of using all this code, in my aspx, i made the Checked value like so:

Checked='<%#DataBinder.Eval(Container.DataItem, "InLocation")%>'
Tags
Grid
Asked by
Alexander
Top achievements
Rank 1
Answers by
Alexander
Top achievements
Rank 1
Share this question
or