Click here to Skip to main content
15,917,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends

I fetch whole the dataset but i want to get single column to bid my dropdown but its return horizontal value

here is my code where is the problem?

C#
DataSet ds = new DataSet();
ds = Content_Data.GetContents();
ddlPageName.DataSource = ds.Tables[0].Rows[0]["PageName"].ToString();
ddlPageName.DataBind();
Posted
Updated 29-Mar-13 13:04pm
v2

1 solution

You must add list item in Dropdownlist for assigning the value ds.Tables[0].Rows[0]["PageName"].ToString(); to that perticular list Item
For example
C#
List<system.web.ui.webcontrols.listitem> colors = new List<system.web.ui.webcontrols.listitem>();
colors.Add(new ListItem("Select Value", "0"));
colors.Add(new ListItem(ds.Tables[0].Rows[0]["PageName"].ToString(), "1"));

</system.web.ui.webcontrols.listitem></system.web.ui.webcontrols.listitem>

And then bind this List to your drop down list

C#
ddlPageName.DataSource = colors;
ddlPageName.DataBind(); 
 
Share this answer
 

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