复选框从SQL数据库值中选择值

复选框从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;	
   }
  }