1

I have a asp.net grid view and i have IsActive field in database and it comes as 1 or 0.So i need according to that value Grid view Checkbox is checked or not.

Grid View Field

<asp:TemplateField>
            <ItemTemplate>
                <asp:CheckBox ID="chkIsActive" DataField="ISACTIVE" HeaderText="Is Active"  runat="server" Checked='<%# Eval("ISACTIVE") %>'/>

            </ItemTemplate>
        </asp:TemplateField>

Code Behind

 GridRes gridRes = NewsProxy.GetAllnews(req);
            gv.DataSource = gridRes.Dataset;
            gv.DataBind();

1 Answer 1

2

If your IsActive field is a bit column and contains only 0 or 1 then you can do like below in order to pre-check or unchech the checkbox.

<asp:CheckBox ID="chkIsActive" DataField="ISACTIVE" HeaderText="Is Active"  runat="server" Checked='<%# Convert.ToBoolean(Eval("ISACTIVE")) %>'/>
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.