Wednesday, 28 August 2013

how to bind check box values on gridview with the values of database table?

how to bind check box values on gridview with the values of database table?

I have a data table column "staff" of type bit. In my grid view i have
added an item template of check boxes. I wants o display the check boxes
checked if the value of "staff" column =1 on data bind. other wise
unchecked.. from searches i have written like this
<ItemTemplate>
<asp:CheckBox ID="chk1" runat="server" Checked='<%#
bool.Parse(Eval("NPstaff").ToString()) %>'/>
</ItemTemplate>
DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter("SELECT id,staff FROM
staff_details ", con1);
adapter.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
but it shows an error "System.FormatException: String was not recognized
as a valid Boolean." please help

No comments:

Post a Comment