Click here to Skip to main content
15,908,445 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
C#
public void getTypes()
      {
        DataTable dttype = new DataTable();
        dttype = fpBAL.getMisctype();
        ddltype.DataSource = dttype;
        ddltype.DataTextField = "productname";
        ddltype.DataValueField = "sno";
        ddltype.DataBind();
        ddltype.Items.Add(new ListItem("--Select--", "0"));
        ddltype.SelectedIndex = ddltype.Items.Count - 1;
     }


my problem is dropdown list is not bind the productname.what's the problem please help me
Posted
Updated 16-Oct-13 20:28pm
v3
Comments
santhu888 17-Oct-13 2:29am    
may be , autopostback properity is not set.please check the properity
Siva Hyderabad 17-Oct-13 2:31am    
autopostback properity is true.but it cant bind

C#
protected void Page_Load(object sender, EventArgs e)
{
  if (!IsPostBack)
  {
     getTypes();
  }
}

try this.
 
Share this answer
 
v2
If possible then also try using DataSet as like: and also make sure to write actual field name within text field and value field and call your function on page load.
C#
DataSet ds = new DataSet();

ds = fpBAL.getMisctype();
ddltype.DataSource = ds.Table[0];
ddltype.DataTextField = "productname";
ddltype.DataValueField = "sno";
ddltype.DataBind();
ddltype.Items.Add(new ListItem("--Select--", "0"));
ddltype.SelectedIndex = - 1;
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900