How to make a multi column drop down list for my asp.net web application

Showing Answers 1 - 2 of 2 Answers

Dhara

  • Sep 15th, 2006
 

Hi

Suppose your existing code is

  ddlDropDown.DataSource  = dtGetData;
  ddlDropDown.DataTextField = "Col1";
  ddlDropDown.DataBind();


Change it to

Assume DataTable dtGetData is your datatable, which has three column col1, col2, col3 comming from DataBase.

 DataTable dtNewData = new DataTable();
        dtNewData .Columns.Add("Display", System.Type.GetType("System.Int16"));
  for (int index= 0; index < oDtUnmapped.Rows.Count; index++)
         {                  
  DataRow dtRow = dtNewData.NewRow();
  dtRow["Display"] = dtGetData.Rows[index]["col1"] +  dtGetData.Rows[index]["col2"] +  dtGetData.Rows[index]["col3"];
  dtNewData.Rows.Add(dtRow);
 }

  ddlDropDown.DataSource  = dtNewData;
  ddlDropDown.DataTextField = "Display";
  ddlDropDown.DataBind();

I hope this 'll help you

  Was this answer useful?  Yes


Suppose your existing code is

  ddlDropDown.DataSource  = dtGetData;
  ddlDropDown.DataTextField = "Col1";
  ddlDropDown.DataBind();


Change it to

Assume DataTable dtGetData is your datatable, which has three column col1, col2, col3 comming from DataBase.

 DataTable dtNewData = new DataTable();
        dtNewData .Columns.Add("Display", System.Type.GetType("System.Int16"));
  for (int index= 0; index < oDtUnmapped.Rows.Count; index++)
         {                  
  DataRow dtRow = dtNewData.NewRow();
  dtRow["Display"] = dtGetData.Rows[index]["col1"] +  dtGetData.Rows[index]["col2"] +  dtGetData.Rows[index]["col3"];
  dtNewData.Rows.Add(dtRow);
 }

  ddlDropDown.DataSource  = dtNewData;
  ddlDropDown.DataTextField = "Display";
  ddlDropDown.DataBind();

I hope this will help you.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions