asp.net - Access code behind members in radiobuttonlist inside gridview -


how can access code behind methods radiobuttonlist insode gridview below? using code blocks of reason not allowed here..

<asp:GridView ID="gvChildren" runat="server" DataKeyField="ID">
<Columns>
<asp:TemplateField>
<ItemTemplate>

<asp:RadioButtonList runat="server" ID="rblAccess">
<asp:ListItem Value="0" Text="<%= Get("test") %>"></asp:ListItem>
<asp:ListItem Value="1" Text="<%= Get("test") %>">dfgdfg</asp:ListItem>
<asp:ListItem Value="2" Text="<%= Get("test") %>"></asp:ListItem>
</asp:RadioButtonList>

</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

i think not possible(databinding expressions supported on objects have databinding event). set text in codebehind. example:

<asp:radiobuttonlist runat="server" id="rblaccess"> <asp:listitem value="0" ></asp:listitem> <asp:listitem value="1" ></asp:listitem> <asp:listitem value="2" ></asp:listitem> </asp:radiobuttonlist> 

codebehind:

protected sub page_load(byval sender object, byval e system.eventargs) handles me.load     if not page.ispostback         me.rblaccess.databind()     end if end sub  private sub rblaccess_databound(byval sender object, byval e system.eventargs) handles rblaccess.databound     each item listitem in rblaccess.items         item.text = getaccesstext(item.value)     next end sub  private function getaccesstext(byval value string) string     return "text item " & value end function 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -