m doing project using MVC approach..
here is a code
1)In .cs
public DataTable bindGrid_ShwVilage(string SubDistname)
{
con = conObj.connect();
con.Open();
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
cmd = new SqlCommand("ShwQuryInGrid_pro", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@SubDistName", SubDistname);
da.SelectCommand = cmd;
da.Fill(dt);
return dt;
}
2).cs act as business layer
public List<DataRow> dataBind(string subDistNm)
{
DataTable dt = shwObj.bindGrid_ShwVilage(subDistNm);
List<DataRow> list = new List<DataRow>();
foreach(DataRow dr in dt.Rows)
{
list.Add(dr);
}
return list;
}
3)aspx.cs(controller)
protected void ButchkL_Click(object sender, EventArgs e)
{
string subDistNm=DdlSubDist.SelectedItem.Text;
List<DataRow> row = shwObj.dataBind(subDistNm);
for (int i = 0; i < row.Count; i++)
{
GridResult.DataSource= row[i].ItemArray.ToString();
//GridResult.DataSource = row[i].ItemArray[1].ToString();
}
GridResult.DataBind();
}
flow of data is fine ..m binding data in two col of GV..but at the time of binding it couldnt find my first column which is integer type...ny other way to get data from itemArray????