2011-02-23 5 views
1

렌더링 그룹 이름은 gridview의 각 라디오 버튼에 대해 다른 이름을 가진 name 속성으로옵니다.render 동안 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 컨트롤을 사용하는 것은 어떻습니까? 이렇게하면 렌더링 대상을 제어 할 수 있습니다.