Master page is loading again(twice)
Hi,
I have 3 dropdownlist controls.. To load i have written a method placed in a separate class which is static.
Here is the method and the page load event.. The master page again loads back erasing all the data to be displayed in the dropdownlist control.. Plzz help me correct me..
this is xyz.aspx:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
load_dropdownlist();
}
}
private void load_dropdownlist()
{
DataSet ds = new DataSet();
ds = PopulateControlsCls.LoadDataSet("Select ProjectID,ProjectName from ProjectDetailsMaster");
drpprojname.DataSource = ds.Tables[0];
drpprojname.DataValueField = "ProjectID";
drpprojname.DataTextField = "ProjectName";
}
==========================================================================
PopulateControlsCls is static class
public static DataSet LoadDataSet(string SQLquery)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ProjectTrackingConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand();
DataSet ds = new DataSet();
//conn = CONN;
cmd.CommandType = CommandType.Text;
cmd.CommandText = SQLquery;
SqlDataAdapter da = new SqlDataAdapter(cmd);
cmd.Connection = conn;
da.SelectCommand = cmd;
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
da.Fill(ds);
conn.Close();
cmd = null;
return ds;
}