private void LoadUsers() { DBConnection d = new DBConnection(); d.OpenConnection(); SqlCommand select = new SqlCommand(); select.CommandText = "Select Distinct Username,UserId from tblUser"; select.Connection = d.myconn; dropdownuser.DataSource = select.ExecuteReader(); dropdownuser.DataTextField = "Username"; dropdownuser.DataValueField = "UserId"; dropdownuser.DataBind(); //Load users }
<asp:DropDownList ID="dropdownuser" runat="server" CssClass="tx_box"> </asp:DropDownList
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LoadUsers(); } }
Select Distinct Username from tblUser
Select Distinct UserId from tblUser
if (!IsPostBack){ //code here }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)