复选框从SQL数据库值中选择值 [英] Checkbox selected value from SQL database value
本文介绍了复选框从SQL数据库值中选择值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿大家,
我有问题。我有两个复选框--cboxMale和cboxFemale。数据库值是M和F.我需要在C#中执行的操作是运行存储过程,返回值,并根据M或F返回检查相应的框。
这是我如何引入价值的一个例子。
Hey everyone,
I have a problem. I have two checkboxes - cboxMale and cboxFemale. The database values are M and F. What I need to do in C# is run a Stored Proc, return the values, and check the appropriate box based on M or F return.
Here's an example of what how I'm bringing in the values.
private void NavigateRecords()
{
dRow = _ds.Tables[0].Rows[Inc];
tbUserId.Text = dRow.ItemArray.GetValue( 1 ).ToString();
tbPrimeLoc.Text = dRow.ItemArray.GetValue( 2 ).ToString();
tbUserName.Text = dRow.ItemArray.GetValue( 3 ).ToString();
tbEmail.Text = dRow.ItemArray.GetValue( 4 ).ToString();
tbDob.Text = dRow.ItemArray.GetValue( 5 ).ToString();
tbEmpId.Text = dRow.ItemArray.GetValue( 6 ).ToString();
//Need checkbox here... Read value from (7) if "M" then cboxMale = checked else if "F" then cboxFemale = checked
}
private void GetUserId()
{
//Sql Stuff Here...
NavigateRecords();
}
有什么想法吗?
Any ideas?
推荐答案
使用以下代码:
Use the Following Code:
private void NavigateRecords()
{
dRow = _ds.Tables[0].Rows[Inc];
tbUserId.Text = dRow.ItemArray.GetValue( 1 ).ToString();
tbPrimeLoc.Text = dRow.ItemArray.GetValue( 2 ).ToString();
tbUserName.Text = dRow.ItemArray.GetValue( 3 ).ToString();
tbEmail.Text = dRow.ItemArray.GetValue( 4 ).ToString();
tbDob.Text = dRow.ItemArray.GetValue( 5 ).ToString();
tbEmpId.Text = dRow.ItemArray.GetValue( 6 ).ToString();
//Need checkbox here... Read value from (7) if "M" then cboxMale = checked else if "F" then cboxFemale = checked
string str="";
str = dRow.ItemArray.GetValue(7).ToString();
if (str == "M")
{
cboMale.Checked = true;
cboFemale.Checked = false;
}
else
{
cboMale.Checked = false;
cboFemale.Checked = true;
}
}
这篇关于复选框从SQL数据库值中选择值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文