hello everybody im trying to display the database values in my dropdown list, i have created stored procedure for it and trying to get the values by calling that stored procedure in my code behind but im not able to display it. please help me out
protected void DrpClientName_SelectedIndexChanged(object sender, EventArgs e)
{
MTMSDTO objc = new MTMSDTO();
{
objc.ClientName = Convert.ToString(Session["ClientName"]);
DataSet ClientN = obj.GetClientList();
DataView Projview = new DataView();
Projview.Table = ClientN.Tables[0];
DrpClientName.DataSource = Projview;
DrpClientName.DataBind();
}
}
Dont write the code in dropdowns selected index changed event write it in a function and call it in pageload event
you have to set the DataTextField and DatavalueField
objc.ClientName = Convert.ToString(Session["ClientName"]);
DataSet ClientN = obj.GetClientList();
DataView Projview = new DataView();
Projview.Table = ClientN.Tables[0];
DrpClientName.DataSource = Projview;
DrpClientName.DataTextField="Description";
DrpClientName.DataValueField="ID";
DrpClientName.DataBind();
you didn't write what you want to display... you have to use DisplayMember ValueMember
.
try this:
objc.ClientName = Convert.ToString(Session["ClientName"]);
DataSet ClientN = obj.GetClientList();
DataView Projview = new DataView();
Projview.Table = ClientN.Tables[0];
DrpClientName.DataSource = Projview;
DrpClientName.DisplayMember = "Column name that you want to display";
DrpClientName.ValueMember = "Column name that you want to get the values from";
Good luck.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.