When I try to databing dropdownlist
, got this: system.data.datarowview
what do I wrong?
string strQuery = "Select Item FROM Calendar Where UserD="Test";
SqlConnection myConn;
SqlDataAdapter sqlDa = new SqlDataAdapter(strQuery,myConn);
DataTable sqlTa = new DataTable("Test");
da.Fill(sqlTa);
ddlList.DataSource = sqlTa;
ddlList.DataBind();
string strQuery = "Select Item FROM Calendar Where UserD='Test'";
Note you need to use single quotations around the string, as in your code you didn't finish the inital string ever, so the rest of the code just became part of strQuery.
In addition if you bring back more than one field in the future, when you bind a dropdown list you need to specify which field from the database is the value and which is the displayed text.
ddlList.DataSource = sqlTa;
ddlList.DataValueField = "ValueFieldFromDatabaseResults";
ddlList.DataTextField = "ShownTextFieldFromDatabaseResults";
ddlList.DataBind();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With