dropdownlist binding from function in code behind aspx vb
Posted
by Dr.H
on Stack Overflow
See other posts from Stack Overflow
or by Dr.H
Published on 2010-05-10T23:57:12Z
Indexed on
2010/05/11
0:04 UTC
Read the original article
Hit count: 243
databinding
so I have this working in C# , why it is not working in VB
public string[] CustomizedRoles()
{
int length = Roles.GetAllRoles().Length;
string[] arrRoles=Roles.GetAllRoles();
string[] customizedRoles= new string[length+1];
customizedRoles[0] = "";
for (int i = 1; i < length+1; i++)
{
customizedRoles[i] = arrRoles[i-1];
}
return customizedRoles;
}
asp:GridView....
asp:DropDownList ID="ddlOwnerRolesUpdate" runat="server" DataSource="<%# CustomizedRoles() %>" Height="25px" Width="177px" SelectedValue='<%# Bind("Owner") %>'>
where is "Owner" is a data value come from a datasource for the grid
it is working fine in C# .
in Vb with the same aspx and this code behind it is not working.
Public Function CustomizedRoles() As String()
Dim length As Integer = Roles.GetAllRoles().Length
Dim arrRoles As String() = Roles.GetAllRoles()
Dim _customizedRoles As String() = New String(length + 1) {}
_customizedRoles(0) = " "
For index As Integer = 1 To length
_customizedRoles(index) = arrRoles(index - 1)
Next
Return _customizedRoles
End Function
can anyone show me how to bind array of string to a dropdownlist from aspx to code behind in VB
© Stack Overflow or respective owner