I have an editform in my webapplication
and I need to retrive the value of the Radio button and the checkboxes saved in my database
for examlpe I have one radiobutton has 4 options : good - bad - v.good - excellent
and one checkbox has 4 items : art - account - marketing ..... and so on
and I'm saving in my Main Table The ID's of the selected value for both radiobutton and checkbox
so for the saving the radiobutton :int state = int.Parse(rdblstate.SelectedValue.ToString());
and for saving the checkbox i'm using a for loop to save it in a seperate table like this
for (i = 0; i < chkbox1.Items.Count; i++)
{
if (chkbox1.Items[i].Selected == true)
{
cmd = new SqlCommand("sp_ADD_Type", con);
cmd.CommandType =CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@ID_TYPE",yy);
cmd.Parameters.AddWithValue("@TYPE",chkbox1.Items[i].Text);
cmd.Connection = con;
cmd.ExecuteNonQuery();
}
I'm saving in my main table only the ID e.g good-->1 bad-->2 and so on
I want now to show the checked value in the edit form also for the checked box checked .
please help me on doing it
Sandeep Singh ShekhawatPosted Apr 10, 2013, 10:32 AM
1. Good
2. Bad
3. Very Good
4. Excellent
We have a user registration that has value is 3 means very good so we want to edit that user than "Very Good" checkbox should be checked.
int chkValue = 3;//that value you retrive from db for that user
for (int i = 1; i <= chkbox1.Items.Count; i++)
{
if (i == chkValue)
{
chkbox1.Items[--chkValue].Selected = true;
break;
}
}
ToBePosted Apr 10, 2013, 4:40 PM