Syed Ali

Syed Ali

  • NA
  • 1
  • 0

Problem in databinding returned columns to the ListBox.

Oct 8 2007 4:52 PM

Hi all,

I am working on my semester project and I am stuck up little and need some help.

List Search is a AJAX control, I want to data bind it to Oracle. How can I do that. As far as I know List Search requires the data to be returned to it as array of strings. Now I am fetching the records from Oracle in a DataSet 'ds'. When I databind 'ds' to that List. It shows System.Data.DataRowView as the ListBox items. What should I do? The following are the code snippets I am using.

public DataSet dbSearch(string query)

{

OracleConnection newCon = new OracleConnection("Data Source=HMS;Persist Security Info=True;User ID=system;Password=manager;Unicode=True");

OracleDataAdapter fetchRecord = new OracleDataAdapter(query, newCon);

DataSet ds = new DataSet();

try

{

newCon.Open();

ds.DataSetName = "Selected patient(s)";

fetchRecord.Fill(ds);

newCon.Close();

}

catch (OracleException ex)

{

string ex0 = ex.ToString();

MessageBox.Show(ex0);

}

catch (Exception exx)

{

string ex00 = exx.ToString();

MessageBox.Show(ex00);

}

return ds;

}

Now, in OnLoad() I am calling this method and passing the variable containing the query.

protected override void OnLoad(EventArgs e)

{

base.OnLoad(e);

string str = "select MED_ID from MEDICINE";

DataSet ds = dbSearch(str);

ListBox1.DataSource = ds;

ListBox1.DataBind();

}

Now what should I do in order to view the actual columns that my query is returning in dataset? Is their any other way, is their any other way through which  I can return the number of columns in an array of strings and databind it to my ListBox. Please help...

Answers (1)