I am populating dropdown into gridview.when i am running application, in dropdown it shows me this data System.Data.Datarawview.
Here I have pasted my code :
public void FindControlInGV()
{
foreach (GridViewRow gvr in gvPopulate.Rows)
{
SqlDataAdapter ad = new SqlDataAdapter("select B_Element from Test_Table", con);
DataSet ds = new DataSet();
ad.Fill(ds, "Test_Table");
DropDownList ddlSelect = new DropDownList();
ddlSelect = (DropDownList)gvr.Cells[0].FindControl("ddlPopulate");
ddlSelect.DataSource = ds;
ddlSelect.DataBind();
}
//}
}
I am new to asp.net pls help me out.

Suthish NairPosted Jul 1, 2011, 8:14 AM
ddlSelect.DataSource = ds.Tables(0)
ddlSelect.DataTextField = "Column name to de displayed to user"
ddlSelect.DataValueField = "Column name for your logic"
ddlSelect.DataBind()
Sahil JaniPosted Jul 1, 2011, 8:26 AM
Jiteendra SampathiraoPosted Jul 1, 2011, 8:17 AM
public void FillDropDownList()
{
s = WebConfigurationManager.ConnectionStrings["ChartDatabaseConnectionString"].ConnectionString;
con = new SqlConnection(s);
con.Open();
cmd = new SqlCommand("Select StudentName from Student", con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
DropDownList1.Items.Add(dr[0].ToString());
}
dr.Close();
con.Close();
}
otherwise...
i think mistake is locates here
ddlSelect = (DropDownList)gvr.Cells[0].FindControl("ddlPopulate");
Sandeep ShekhawatPosted Jul 1, 2011, 8:15 AM
}
use this this symptoms comes for dropdown list that have no value and text filed.