private void PopulateGrid(GridView gv, Int32 pageindex, DataSet dsGV)
{
try
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
DataRow[] dr = null;
string exp = "rowno = " + pageindex;
if (dsGV.Tables[0].Rows.Count > 0)
dr = dsGV.Tables[0].Select(exp);
ds = dsGV.Clone();
foreach (DataRow drr in dr)
ds.Tables[0].ImportRow(drr);
gv.DataSource = ds;
gv.DataBind();
//following code is written to get current level description from id_member_levels table
//this is written to avoid join in the main query
//if we give join in main query in Populate proceure, it affects on the performance of the query.
if (ds.Tables[0].Rows.Count > 0)
{
if (cn.State == ConnectionState.Closed)
{
cn.Open();
cm = new OleDbCommand("", cn);
}
}
//for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
//{
// if (ds.Tables[0].Rows[i]["MM_CURR_LEVEL"].ToString().Equals("0") == false)
// {
// strSQL = "select ML_DESC from id_member_levels where ml_level = " + ds.Tables[0].Rows[i]["MM_CURR_LEVEL"].ToString();
// cm.CommandText = strSQL;
// reader = cm.ExecuteReader();
// if (reader.Read())
// gv.Rows[i].Cells[c_Level].Text = reader["ML_DESC"].ToString();
// reader.Close();
// }
// else
// gv.Rows[i].Cells[c_Level].Text = "NA";
//}
if (cn.State == ConnectionState.Open)
{
cm.Dispose();
cn.Close();
}
}
catch (Exception ex) { lblError.Text = ex.Message; }
finally { }
}
{
try
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
DataRow[] dr = null;
string exp = "rowno = " + pageindex;
if (dsGV.Tables[0].Rows.Count > 0)
dr = dsGV.Tables[0].Select(exp);
ds = dsGV.Clone();
foreach (DataRow drr in dr)
ds.Tables[0].ImportRow(drr);
gv.DataSource = ds;
gv.DataBind();
//following code is written to get current level description from id_member_levels table
//this is written to avoid join in the main query
//if we give join in main query in Populate proceure, it affects on the performance of the query.
if (ds.Tables[0].Rows.Count > 0)
{
if (cn.State == ConnectionState.Closed)
{
cn.Open();
cm = new OleDbCommand("", cn);
}
}
//for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
//{
// if (ds.Tables[0].Rows[i]["MM_CURR_LEVEL"].ToString().Equals("0") == false)
// {
// strSQL = "select ML_DESC from id_member_levels where ml_level = " + ds.Tables[0].Rows[i]["MM_CURR_LEVEL"].ToString();
// cm.CommandText = strSQL;
// reader = cm.ExecuteReader();
// if (reader.Read())
// gv.Rows[i].Cells[c_Level].Text = reader["ML_DESC"].ToString();
// reader.Close();
// }
// else
// gv.Rows[i].Cells[c_Level].Text = "NA";
//}
if (cn.State == ConnectionState.Open)
{
cm.Dispose();
cn.Close();
}
}
catch (Exception ex) { lblError.Text = ex.Message; }
finally { }
}