N
news.sbcglobal.net
Can anyone tell me how to fix this so that my drop down list is not empty
when the page loads (ASP.NET 2.0). Thanks!:
------------------------------
HTML
-----------------------------
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true"
CodeFile="UserManager.aspx.vb" Inherits="Admin_UserManager" Title="User
Manager" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
runat="Server">
<h2>
User Manager</h2>
Roles:
<aspropDownList ID="DropDownList1" runat="server">
</aspropDownList>
<asp:Button ID="Button1" runat="server" Text="Get Users In Role"
OnClick="Button1_Click" />
<p>
<asp:GridView ID="GridView1" runat="server" />
</p>
</asp:Content>
------------------------------------
CODE
-----------------------------------
Partial Class Admin_UserManager
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
DropDownDataBind()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
GridView1.DataSource =
Roles.GetUsersInRole(DropDownList1.SelectedValue)
GridView1.DataBind()
DropDownDataBind()
End Sub
Protected Sub DropDownDataBind()
DropDownList1.DataSource = Roles.GetAllRoles()
End Sub
End Class
when the page loads (ASP.NET 2.0). Thanks!:
------------------------------
HTML
-----------------------------
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true"
CodeFile="UserManager.aspx.vb" Inherits="Admin_UserManager" Title="User
Manager" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
runat="Server">
<h2>
User Manager</h2>
Roles:
<aspropDownList ID="DropDownList1" runat="server">
</aspropDownList>
<asp:Button ID="Button1" runat="server" Text="Get Users In Role"
OnClick="Button1_Click" />
<p>
<asp:GridView ID="GridView1" runat="server" />
</p>
</asp:Content>
------------------------------------
CODE
-----------------------------------
Partial Class Admin_UserManager
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
DropDownDataBind()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
GridView1.DataSource =
Roles.GetUsersInRole(DropDownList1.SelectedValue)
GridView1.DataBind()
DropDownDataBind()
End Sub
Protected Sub DropDownDataBind()
DropDownList1.DataSource = Roles.GetAllRoles()
End Sub
End Class