在网页上显示单选按钮C#的数据库值 [英] Display databases value of radio button C# on webpage
本文介绍了在网页上显示单选按钮C#的数据库值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
很抱歉对此如此陌生,但我和我已经想出如何将表单条目保存到数据库中,但现在我希望它们显示在编辑页面上,以便可以更新值。我正在使用C#,我正在使用存储过程从数据库中提取数据并为表单显示它。我已经尝试了以下方法来获取一个真/假的单选按钮,以显示数据库中的值是什么,这是真的,存储过程将其拉回1.
我尝试过:
Sorry to be so new to this, but I am and I have figured out how to save my form entries to the database however now I want them to display on an edit page so the values can be updated. I am working with C# and I am using a stored procedure to pull the data out from the database and surface it for the form. I have tried the following to get a true/false radio button to display as what the value is in the DB which is true and the stored procedure pulls it back as 1.
What I have tried:
<pre>if (chkAllRadioButton.Checked = Details.chkAllRadioButton.ToString() == "true")
{
chkAllRadioButton.Checked = true;
}
//and I have tried
if (chkAllRadioButton.Checked = Details.chkAllRadioButton.ToString() == "1")
{
chkAllRadioButton.Checked = true;
}
推荐答案
如果您的存储过程
返回1
this will do the job if yourstored procedure
returns "1"
chkAllRadioButton.Checked = Details.chkAllRadioButton.ToString() == "1";
这篇关于在网页上显示单选按钮C#的数据库值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文