dropdown list control populating with db query as well as default one

  • Thread starter Thread starter mamun
  • Start date Start date
M

mamun

Hi All,

The problem is as follows:

I have a table from where I am getting consultant's name and
populating the dropdown list control. But I want to populate the
default one which I got it as a query string from the previous page.
How can I do that?

I do appreciate your help.

Thanks a ton in advance.

Best regards,

mamun
 
Get the default from the querystring, and add it as an additional DataRow to
the table that you are binding to, before calling the DataBind method. You
can use the InsertAt method of the DataTable class to put the row at the
beginning.
Peter
 
Hi Peter,

Here is the code I am using:

//this is the query I was using:
string qry = "select consult from Consultants where consult<>'"+
strCONSULT + "' order by consult";
//strCONSULT is the variable coming from the previous page as query
string
OracleDataAdapter objDA = new OracleDataAdapter(qry, oraConnection);
DataSet dsConsult = new DataSet();
objDA.Fill(dsConsult, "Table");

ddlConsultant.DataSource = dsConsult.Tables[0].DefaultView;
ddlConsultant.DataTextField =
dsConsult.Tables[0].Columns["Consult"].ColumnName.ToString();
ddlConsultant.DataValueField =
dsConsult.Tables[0].Columns["Consult"].ColumnName.ToString();
ddlConsultant.DataBind();

I want the first item of the dropdown control will be the value of
strCONSULT.

Could you please tell me how I could implement your ideas in the above
codes.

I do appreciate your help.

Thanks a ton in advance.

best regards,
mamun
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top