SqlConnection con = new SqlConnection(ConnStr);string strQuery = "select EmpName,ID from emp where Id>100"; SqlDataAdapter ada = new SqlDataAdapter(strQuery, con); DataSet lds = new DataSet(); ada.Fill(lds);ddlname.DataSource = lds;ddlname.DataTextField = "Empname"ddlname.DataValueField = "Id"ddlname.DataBind();ddlName.Items.Insert(0, "-Select-");
using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Give your connection string here"); string SQLQuery= "select categoryID,ID from categorymaster"; SqlDataAdapter ads = new SqlDataAdapter(SQLQuery, con); DataSet ds = new DataSet(); ads.Fill(ds);DropDownList1.DataSource = ds;DropDownList1.DataTextField = "categoryID";DropDownList1.DataValueField = "Id";DropDownList1.DataBind(); }}
Thanks & RegardsG.RenganathanNothing is mine ,Everything is yours!!!