views:

47

answers:

1

I am writing a condition like:

if (dt > 0)
{
   objinvoice.editInvoice(strInvoice, strRenew, strExpiry);
   GridView1.EditIndex = -1;
   bindGrid();
}

I will have a radio button in gridview if that radiobutton is initially set to false and if the condition is true I would like to set it to true ....

+1  A: 

You can do this in gridview itemdatabound event. You can check the condition and change the radiobutton status.

Gridview ItemDataBound example:

private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==System.Web.UI.WebControls.ListItemType.EditItem)

RadioButton rBtnTest = e.Item.FindControl("radiobutton id") as RadioButton;
// Check condition and if it's true
if(your_condition == true)
 rBtnTest.Checked = true;
else
 rBtnTest.Checked = false;
}
kad1r
How can i save that in my database like if i checked=true i would like to save as Yes if not No
Dorababu
Bind the checked value in your markup
Jeroen
I don't understand your question Dorababu. Please repeat clearly.
kad1r
suppose initially the radio button text will be false ... As per your given code it will set to Yes then how can i store it in my data base like if Yes radio button is selected i would like to change the No field to Yes
Dorababu