1

What is the code needed to show a checkbox in a column of a declared datatable?

In C#:

    DataTable dt = new DataTable();
    dt.Columns.Add("DeleteFlag");

In ASP:

    <asp:CheckBox ID="MyCheckBox" runat="server" Checked='<%# Bind("DeleteFlag") %>'
                Enabled="False" />

Error:

Specified cast is not valid.

Troubleshooting tips:

When casting from a number, the value must be a number less than infinity

3
  • what are you trying to do exactly? Bind a checkbox from grid? Commented Feb 24, 2014 at 2:20
  • Yes. Or any way to successfully declare a checkbox. Commented Feb 24, 2014 at 2:22
  • Try this stackoverflow.com/questions/6445178/… Commented Feb 24, 2014 at 2:23

1 Answer 1

1
dt.Columns.Add("DeleteFlag", typeof(bool));

give the correct column data type as above

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.