PERFORMENCE ISSUE
ok here is a the problem i and my partner have an argument over some coding which will be more faster the purpose is to bind dropdownlist
I have written a code which take the control as parameter and my partner wans to bind every control individually.here is two codes
What I written:
public bool FillDropDownList(DropDownList dDl,string TableName,string DataTextField,string DataValueField)
{
string Select="SELECT "+DataTextField+", "+DataValueField+" FROM "+TableName+"";
OleDbConnection conn=new OleDbConnection();
string connString = ConfigurationSettings.AppSettings["connectionstring"];
conn.ConnectionString=connString;
OleDbCommand m_Command = new OleDbCommand(Select,conn);
try
{
dDl.DataValueField = DataValueField;
dDl.DataTextField = DataTextField;
conn.Open();
OleDbDataReader m_DataReader = m_Command.ExecuteReader();
dDl.DataSource = m_DataReader;
dDl.DataBind();
m_DataReader.Close();
}
catch
{
return false;
}
finally
{
m_Command.Dispose();
conn.Close();
conn.Dispose();
}
return true;
}
and what my partner wrttien:
private void BindLoanAppliedCombo()
{
string strSQL = string.Empty;
strSQL = " SELECT * FROM LOAN_TYPE";
SystemUtility.SystemUtility util = new SystemUtility.SystemUtility();
Listloanappliedfor.DataSource = util.RetrieveRS(strSQL);
Listloanappliedfor.DataTextField = "LOAN_TYPE";
Listloanappliedfor.DataValueField = "LOAN_TYPE_ID";
Listloanappliedfor.DataBind();
}
Please help to end this argument
|