Multiple DataTextField In Dropdownlist in Asp.Net C#



  1.   DataTable dt = ds.Tables[0];

  2.   if (dt.Rows.Count > 0)
  3.                     {
  4.                         Dictionary<int, string> lst = new Dictionary<int, string>();
  5.                         foreach (DataRow row in dt.Rows)
  6.                         {
  7.                             //Add values to Dictionary
  8.                             string val = row[1].ToString() + " " + row[2].ToString() + " - " + row[3].ToString();
  9.                             lst.Add(Convert.ToInt32(row[0]), val);
  10.                         }

  11.                         dllVendorName.DataSource = lst;
  12.                         dllVendorName.DataTextField = "Value";
  13.                         dllVendorName.DataValueField = "Key";
  14.                         dllVendorName.DataBind();
  15.                     
  16.                     }
Example:


Comments

  1. Good Job Mr. Mehul Sir
    Can you please send me query about return type using same method name and same number of variables and same variable....?
    my mail id is vickyduvey733@gmail.com

    ReplyDelete

Post a Comment

Popular posts from this blog

Validate Mobile Number with 10 Digits in ASP.Net