Sunday, 29 September 2013

Insert checkbox value to SQL from gridview

Insert checkbox value to SQL from gridview

In a ASP page I have a gridview with a foot row to insert data into the
database. I can successfully insert the text values in the db but I have
problems to insert a checkbox value instead.
This is my code for text value and for the checkbox value:
SqlDataSource1.InsertParameters["umail"].DefaultValue =
((TextBox)GridView1.FooterRow.FindControl("txtUmail")).Text;
SqlDataSource1.InsertParameters["is_admin"].DefaultValue =
((Boolean)GridView1.FooterRow.FindControl("CheckBox1")).Checked;
SqlDataSource1.Insert();
_____________________________________
<InsertParameters>
<asp:Parameter Name="umail" Type="String" />
<asp:Parameter Name="is_admin" Type="Boolean" />
</InsertParameters>
The second line is the one that is giving me troubles. I keep getting
errors of different types or exceptions. I have tried in several ways
using Boolean, checkBox so I am not reporting all the errors I got here,
but I am not coming right. I would appreciate some help on how should I
write that line to store the checkbox value into the db?

No comments:

Post a Comment