Wednesday, June 1, 2011

dropdown Bind or Add items in DropDownList with array and also add value and text saperately

 for (int count = 0; count < ds.Tables[0].Rows.Count; count++)
                                {
                                    strBrandname += ";" + Convert.ToString(ds.Tables[0].Rows[count]["BRANDNAME"]);
                                    strBrandid += ";" + Convert.ToString(ds.Tables[0].Rows[count]["BRANDID"]);
                                }
                                strBrandname = strBrandname.TrimStart(';');
                                strBrandid = strBrandid.TrimStart(';');
                                strTotalBrand = strBrandname + "-" + strBrandid;

                                string[] brand = Regex.Split(strBrandname, ";");
                                string[] BrandID = Regex.Split(strBrandid, ";");
                                DrpBrand.DataSource = "";
                                DrpBrand.DataBind();
                                for (int i = 0; i < brand.Length; i++)
                                {
                                    DrpBrand.Items.Add(new ListItem(brand[i],BrandID[i]));
                                }
                               

SQL Optimization

  SQL Optimization  1. Add where on your query  2. If you remove some data after the data return then remove the remove condition in the sel...