create this function in global class file(Class1.cs)-
public void bindddl(DropDownList ddlid, string query, string tf, string vf)
{
ds.Clear();
cmd.CommandText = query;
adp.Fill(ds, "vt");
ddlid.DataSource = ds.Tables["vt"];
ddlid.DataTextField = tf;
ddlid.DataValueField = vf;
ddlid.DataBind();
}
// Calling of this function //
public partial class managecourse : System.Web.UI.Page
{
connection c = new connection();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
c.bindddl(ddlcourse,"select * from course_master","course_name","course_id");
ddlcourse.Items.Insert(0,"Select course");
}
}
}
No comments:
Post a Comment