public Boolean FillCombo(ref DropDownList DD1, string DisplayColumn, string ValuColumn, string TableName)
{
try
{
string QueryString = "";
QueryString = "select " + DisplayColumn + "," + ValuColumn + " from " + TableName + " order by " + DisplayColumn;
cmd = new SqlCommand(QueryString, ObjCn.OpenDb());
DA = new SqlDataAdapter(cmd);
DtMain = new DataTable(TableName);
DA.Fill(DtMain);
DD1.DataTextField = DisplayColumn;
DD1.DataValueField = ValuColumn;
DD1.DataSource = DtMain;
DD1.DataBind();
ListItem LtSelect = new ListItem("Select", "0");
DD1.Items.Insert(0, LtSelect);
return true;
}
catch (Exception ex)
{
return false;
}
finally
{
ObjCn.CloseDB();
cmd.Dispose();
DA.Dispose();
}
}
{
try
{
string QueryString = "";
QueryString = "select " + DisplayColumn + "," + ValuColumn + " from " + TableName + " order by " + DisplayColumn;
cmd = new SqlCommand(QueryString, ObjCn.OpenDb());
DA = new SqlDataAdapter(cmd);
DtMain = new DataTable(TableName);
DA.Fill(DtMain);
DD1.DataTextField = DisplayColumn;
DD1.DataValueField = ValuColumn;
DD1.DataSource = DtMain;
DD1.DataBind();
ListItem LtSelect = new ListItem("Select", "0");
DD1.Items.Insert(0, LtSelect);
return true;
}
catch (Exception ex)
{
return false;
}
finally
{
ObjCn.CloseDB();
cmd.Dispose();
DA.Dispose();
}
}