|
此文章由 porcorosso 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 porcorosso 所有!转贴必须注明作者、出处和本声明,并保持内容完整
学C#,碰到问题:
In the Formview, I have a field thats with Checkbox. In the database this column is named 'Status' with Tinyint as datatype. Now, when I show particular item from database to the screen, I do this:- <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Convert.ToBoolean(Eval("status")) %>' />
复制代码 which is fine (but not sure if it is best practise)
The problem is when I like to save. VS generate the code for me as below:- <asp:SqlDataSource ID="SqlDataSource1" runat="server"
- ConnectionString="<%$ ConnectionStrings:testdemoConnectionString %>"
- SelectCommand="SELECT * FROM [test_table_1] WHERE ([id] = @id)"
- DeleteCommand="DELETE FROM [test_table_1] WHERE [id] = @id"
- InsertCommand="INSERT INTO [test_table_1] ([name], [email], [status]) VALUES (@name, @email, @status)"
- UpdateCommand="UPDATE [test_table_1] SET [name] = @name, [email] = @email, [status] = @status WHERE [id] = @id">
复制代码 which is null when the checkbox is untick. instead of having an extra hidden field in the form to mimic this checkbox value as int/string, is there any other way to store this value into database, directly from the form? |
评分
-
查看全部评分
|