luckyads 0 Light Poster

Hi,

I have a datagrid with 2 checkbox columns

<Columns>
<asp:TemplateColumn HeaderText="Part A" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:checkbox runat="server" ID="partOne_Edit" checked='<%# DataBinder.Eval(Container, "DataItem.partOne") %>' Enabled = '<%# IIf(DataBinder.Eval(Container, "DataItem.partOne"), "True" ,"False" )%>'></asp:checkbox>
</ItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="Part B" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:checkbox runat="server" ID="partTwo_Edit" checked= '<%# DataBinder.Eval(Container, "DataItem.partTwo") %>'></asp:checkbox>
</ItemTemplate>

</asp:TemplateColumn>
</Columns>

Now, depending on the values in the xml, I want them enabled and disabled. Also, if 'partTwo_Edit' is checked I want the 'partOne_Edit' to be also checked, but not vice-a-versa. Currently, Enabled = '<%# IIf(DataBinder.Eval(Container, "DataItem.partOne"), "True" ,"False" )%>' does not fulfill my condition as on datagrid bind, the 'partOne_Edit' is disabled.

I have this code in the code-behind-

Dim ptOne As CheckBox = CType(dgitem.Cells(1).FindControl("partOne_Edit"), CheckBox)
Dim ptTwo As CheckBox = CType(dgitem.Cells(2).FindControl("partTwo_Edit"), CheckBox)

If ptOne.Checked = True Then
      objdata.Tables(0).Rows(intRow)("partOne") = 1
      ptOne.Enabled = True
Else
      objdata.Tables(0).Rows(intRow)("partOne") = 0
End If

If ptTwo.Checked = True Then
     objdata.Tables(0).Rows(intRow)("partOne") = 1
     ptOne.Enabled = False
     objdata.Tables(0).Rows(intRow)("partTwo") = 1
Else
     ptOne.Enabled = True
     objdata.Tables(0).Rows(intRow)("partTwo") = 0
End If

How can i use 'Enabled' attribute in the datagrid for this?


Thanks in advance,
Aditi