2011-02-23 95 views
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); 
} 

谢谢。

回答

0

如何使用HTML控件而不是.Net的?这应该让你控制渲染的内容。