I try to bind data to my listbox but in listbox I see "System.Data.Common.DbDataReader" where am I doing wrong?
You can see my code below
......
......
string ins="select CategoryName from Category;";
SqlConnection con=new SqlConnection(connstr);
SqlCommand com=new SqlCommand(ins,con);
try
{
con.Open();
SqlDataReader dr=com.ExecuteReader();
kategori.DataSource=dr;
kategori.DataBind();
}
......
......
For ListBox and DropDownList you need to set the control's DataTextField and DataValueField as well as the DataSource before calling DataBind().
0 comments:
Post a Comment