开发者

Retrieve stored checkbox value from sql server database to re-enable it

I have checkbox value in the gridview which is bound to item template in this m开发者_JAVA技巧anner:

<ItemTemplate>
 <asp:CheckBox ID="CheckBoxDisable" runat="server" AutoPostBack="true" OnCheckedChanged="CheckBoxDisableEvent"/>
</ItemTemplate>

And i'm implementing the CheckBoxDisableEvent method in this manner which does nothing but store the checkbox checked value into sql server table.

        SqlCommand cmd = new SqlCommand("InsertDisableFlagIntoComponents", connection);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add("@disableFlag", SqlDbType.Int).Value = disableFlag;

Now the problem is when the gridview loads on the start of the project next time, i want to enable all those checkboxes depending upon the value that i have stored in database during previous events.

How can i enable the checkbox values in gridview depending on the values that i stored in sql server table.

BTW i'm using vs2008 with asp.net/C#, sqlserver 2005

Thanks in anticipation


<asp:CheckBox ID="CheckBoxDisable" runat="server" Enabled='<%# Convert.ToBoolean(Eval("ColumnName")) ? true : false %>' Checked='<%# Eval("ColumnName") %>' />


<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Eval("ColumnName") == true ? false : true %>'  />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜