1
渲染組名稱出現在gridview中每個單選按鈕的名稱屬性名稱不同後。在渲染時更改gridview中單選按鈕的名稱
我試圖將所有名稱設置爲相同。但是當我們在瀏覽器中看到源代碼時,它是唯一的。
如何更改gridview中所有單選按鈕的名稱。
protected override void Render(HtmlTextWriter writer)
{
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
base.Render(htw);
htw.Close();
string h = sw.ToString();
RadioButton first = (RadioButton)gvAddOption.Rows[0].Cells[3].FindControl("rblValue");
string uniqGroupName = first.UniqueID;
uniqGroupName = uniqGroupName.Replace(first.ID, first.GroupName);
foreach (GridViewRow row in gvAddOption.Rows)
{
RadioButton val = (RadioButton)row.Cells[3].FindControl("rblValue");
string eachGroupName = val.UniqueID;
eachGroupName = eachGroupName.Replace(val.ID, val.GroupName);
//h.Replace("name=\"" + eachGroupName + "\"", "name=\"" + uniqGroupName + "\"");
h.Replace(eachGroupName, uniqGroupName);
}
writer.Write(h);
}
謝謝。