System.Data.DataRowView

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When using a dropdownlist in a web app I get the following in the listbox when I run the app

System.Data.DataRowView. I tried to convert this using the ToString() method to no avail

The code is as follows

private void Page_Load(object sender, System.EventArgs e

BindList()



public DataView CreateDataSource(

string userConnect = "Provider=\"MSDAORA.1\";" + GetConnectionString() + ""
string programSelect = "Select wo9 from Workorder where wo9 <> ' '"
oda = new OleDbDataAdapter(programSelect, programConnect)
DataSet ds = new DataSet()

oda.Fill(ds, "program")
DataView program = ds.Tables["program"].DefaultView
return program



public void BindList(

projectList.DataSource = CreateDataSource()
projectList.DataBind()
projectList.ToString()


How do i cure this

Thanks

Dave
 
Dave,
You also need to set the ListBox.DataValueField & ListBox.DataTextField
properties.

Hope this helps
Jay
 
Dave,
Have you tried something like:
public void BindList()
{
projectList.DataSource = CreateDataSource();
projectList.DataValueField = "field1";
projectList.DataTextField = "field2";
projectList.DataBind();
projectList.ToString();
}

Where field1 & field2 are field names from your Workorder table, from your
earlier sample it appears you can simply use "wo9" for both as that is the
only field you are returning. You could however use:

projectList.DataValueField = "ID";
projectList.DataTextField = "Description";

Where ID is the key field of a table, while Description is the human
readable text.

Hope this helps
Jay
 
Back
Top