4

I need to bind the Checkbox within the gridview with Integer datafield of database.

Actually, when the field value is 1 the checkbox should be checked itself and when 2 it should be unchecked itself.

Code i have tried is as follows but they are not working properly.

<asp:CheckBox ID="chkstatus" runat="server" Checked='<%# 
Bind("status") %>'

<asp:CheckBox ID="chkstatus" 
runat="server" Checked='<%# DataBinder.Eval(Container.DataItem, "status") %>'
0

1 Answer 1

7

You bind like...

<asp:CheckBox ID="CheckBox1" runat="server" 
     Checked='<%# Eval("status").ToString() == "1" ? true : false) %>' />
Sign up to request clarification or add additional context in comments.

1 Comment

<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Eval("status").ToString() == "1" ? true : false %>' />

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.