我有一个gridview,每行都有下拉列表,我想如果用户在一个下拉列表中选择值,那么他可能不会选择另一个下拉列表,但如果他选择那么它应该通过错误:
抱歉,您可以一次选择1个值
int count = 0;
protected void ddlIsComplaint_SelectedIndexChanged(object sender, EventArgs e) //not used yet
{
count = count + 1;
DropDownList ddl = (DropDownList)sender;
GridViewRow row = (GridViewRow)ddl.NamingContainer;
//int ID = Convert.ToInt32(row.Cells[0].Text);
//short IsComplaint = Convert.ToInt16(ddl.SelectedValue);
HiddenFieldIsValidDropDownValue.Value = row.Cells[0].Text;
int RowID = Convert.ToInt16(HiddenFieldIsValidDropDownValue.Value);
if (count >= 1)
{
lblSelectionMessage.InnerText = count.ToString();
}
}
答案 0 :(得分:0)
Label1.Text = "yes";
protected void ddlIsComplaint_SelectedIndexChanged(object sender, EventArgs e) //not used yet
{
if(Label1.Text!="No")
{
DropDownList ddl = (DropDownList)sender;
GridViewRow row = (GridViewRow)ddl.NamingContainer;
//int ID = Convert.ToInt32(row.Cells[0].Text);
//short IsComplaint = Convert.ToInt16(ddl.SelectedValue);
HiddenFieldIsValidDropDownValue.Value = row.Cells[0].Text;
int RowID = Convert.ToInt16(HiddenFieldIsValidDropDownValue.Value);
}
else
{
lblSelectionMessage.InnerText = count.ToString();
}
}