Click here to Skip to main content
15,901,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

C#
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
  }


C#
private void GetUserId()
   {
    //Sql Stuff Here...
    NavigateRecords();
   }

Any ideas?
Posted

1 solution

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;	
   }
  }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900