C# 如何在没有选择的情况下将单选按钮切换为是或否
我在写一个条件,比如:C# 如何在没有选择的情况下将单选按钮切换为是或否,c#,asp.net,gridview,C#,Asp.net,Gridview,我在写一个条件,比如: if (dt > 0) { objinvoice.editInvoice(strInvoice, strRenew, strExpiry); GridView1.EditIndex = -1; bindGrid(); } 如果该单选按钮最初设置为false,我将在gridview中有一个单选按钮,如果条件为true,我希望将其设置为true….您可以在gridview itemdatabound事件中执行此操作。 您可以检查条件并更改radiob
if (dt > 0)
{
objinvoice.editInvoice(strInvoice, strRenew, strExpiry);
GridView1.EditIndex = -1;
bindGrid();
}
如果该单选按钮最初设置为false,我将在gridview中有一个单选按钮,如果条件为true,我希望将其设置为true….您可以在gridview itemdatabound事件中执行此操作。 您可以检查条件并更改radiobutton状态 Gridview项数据绑定示例:
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;
}
我怎样才能把它保存在我的数据库中,比如如果我选中了=真,我想保存为是,如果不是,我不明白你的问题多拉巴布。请清楚地重复。假设最初单选按钮文本为假。。。根据您给定的代码,它将设置为是,那么我如何将其存储在数据库中,如选择了“是”单选按钮,我想将“否”字段更改为“是”