SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Master"].ConnectionString);
SqlTransaction tran=null ;
SqlCommand cmd;
SqlDataAdapter adp;
DataSet ds;
public void filldropdown(DropDownList ddl, string table, string DataTextField, string DataValueField)
{
adp = new SqlDataAdapter("Select " + DataValueField + "," + DataTextField + " from " + table + " order by '" + DataTextField + "' ", con);
DataSet ds = new DataSet();
adp.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
ddl.Items.Add(ds.Tables[0].Rows[i][DataTextField].ToString());
ddl.Items[i + 1].Value = ds.Tables[0].Rows[i][DataValueField].ToString();
}
}
}
Wednesday, July 28, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment