Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在没有选择的情况下将单选按钮切换为是或否_C#_Asp.net_Gridview - Fatal编程技术网

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;
}

我怎样才能把它保存在我的数据库中,比如如果我选中了=真,我想保存为是,如果不是,我不明白你的问题多拉巴布。请清楚地重复。假设最初单选按钮文本为假。。。根据您给定的代码,它将设置为是,那么我如何将其存储在数据库中,如选择了“是”单选按钮,我想将“否”字段更改为“是”