在GridView的RowDataBound
事件我設置的HtmlInputRadioButton
GridViewRow
內的名稱。問題是,asp.net自動使名稱獨特,因此取消了單選按鈕的組合。ASP.NET設置GridView中的HtmlInputRadioButton名稱後面的代碼
有沒有辦法讓我禁用?
編輯 - 下面是我如何設置名稱:中
<input type="radio" id="ctl00_ContentPlaceHolder1_ucFoo_gvFoo_ctl06_rbFoo" name="Foo" value="A Value">
<input type="radio" id="ctl00_ContentPlaceHolder1_ucFoo_gvFoo_ctl07_rbFoo" name="Foo" value="A Value">
Private Sub gvFoo_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvSecPos.RowDataBound
If Not (e.Row.RowType = DataControlRowType.DataRow) OrElse (e.Row.Cells(0) Is Nothing) Then
Return
End If
Dim drFoo As DataRowView = CType(e.Row.DataItem, DataRowView)
Dim rbFoo As HtmlInputRadioButton = CType(e.Row.FindControl("rbFoo"), HtmlInputRadioButton)
rbFoo.Name = "Foo" 'ASP.NET makes this unique which I do not want
rbFoo.Value = "A Value"
End Sub
產生這個網站
<input type="radio" id="ctl00_ContentPlaceHolder1_ucFoo_gvFoo_ctl06_rbFoo" name="ctl00$ContentPlaceHolder1$ucFoo$gvFoo$ctl06$Foo" value="A Value">
<input type="radio" id="ctl00_ContentPlaceHolder1_ucFoo_gvFoo_ctl07_rbFoo" name="ctl00$ContentPlaceHolder1$ucFoo$gvFoo$ctl07$Foo" value="A Value">
而是由於數字 「106」 和「 107「,以其拆分它們的相應單選按鈕的名義。
一個例子當你說「名字」你的意思是服務器端控件的ID或客戶端輸入名稱? – jrummell 2011-01-06 16:28:29
客戶端輸入名稱 – Drahcir 2011-01-06 16:31:19
它如何使它獨一無二?它流出了什麼? – 2011-01-06 16:34:50