I have a Checkboxfield in my gridview. I'm creating the columns for the gridview in code behind with the code below. Everything works, but I need the checkboxes not to be read only. But What I've figured out is that you have to put the grid into edit mode first. Is there a way around this.
I could use a real checkbox inside of a templatefield, but then I would have to write a routine to check or uncheck the checkbox based on the data returned.
Plus I have no idea how to create a template field from code behind.
Thanks for any Help!!!
I could use a real checkbox inside of a templatefield, but then I would have to write a routine to check or uncheck the checkbox based on the data returned.
Plus I have no idea how to create a template field from code behind.
Thanks for any Help!!!
VB.NET:
Sub populateVariantList()
gv_VariantList.Columns.Clear()
Dim Ds As DataSet
Ds = New DataSet
Ds = Core.Data.PopulateVariantList(ProductID)
gv_VariantList.Columns.Clear()
gv_VariantList.AutoGenerateColumns = False
Dim HiddenField As New BoundField
HiddenField.DataField = "ProductVariantID"
HiddenField.Visible = False
Dim Col As DataControlField = HiddenField
gv_VariantList.Columns.Add(Col)
Dim Field As New BoundField
Field.DataField = "ProductVariantName"
Field.HeaderText = "Product Name"
Col = Field
gv_VariantList.Columns.Add(Col)
Field = New BoundField
Field.DataField = "ProductVariantDescription"
Field.HeaderText = "Description"
Col = Field
gv_VariantList.Columns.Add(Col)
Field = New BoundField
Field.DataField = "Price"
Field.HeaderText = "Price"
Col = Field
gv_VariantList.Columns.Add(Col)
Dim chkbox As CheckBoxField
chkbox = New CheckBoxField
chkbox.HeaderText = "Select"
chkbox.DataField = "chk"
chkbox.ReadOnly = False
Col = chkbox
gv_VariantList.Columns.Add(Col)
gv_VariantList.DataSource = Ds.Tables(0)
gv_VariantList.DataBind()
End Sub