Hello,
I am working an MVC3 application where I need to make use of the MVC Grid.
Now as I am not abale to bind my datatable with the MVC grid. beloow is the controller code using which I am displaying certain data in the pages. It has a model name PartyHomeModel. There's a datatable in the model along with other variables. I am filling these from my database as given below.:-
/*
public ActionResult PartyHome()
{
DataManager DM = new DataManager();
PartyHomeModel pmodel=new PartyHomeModel();
string SQL = " select p.*,u.mines_name from PARTY_MASTER p inner join UNIT_MASTER as u on p.MINES_CODE=u.ore_mines_code where p.PARTY_CODE='" + Session["user_ID"] + "' and p.MINES_CODE='" + Session["mines"] + "' ";
DataTable DT2 = new DataTable();
DT2 = DM.GetDataTable(SQL);
pmodel.MINES_CODE = DT2.Rows[0]["MINES_CODE"].ToString();
pmodel.PARTY_CODE = DT2.Rows[0]["PARTY_CODE"].ToString();
pmodel.mines_name = DT2.Rows[0]["mines_name"].ToString();
pmodel.PAN = DT2.Rows[0]["PAN"].ToString();
pmodel.PARTY_NAME = DT2.Rows[0]["PARTY_NAME"].ToString();
pmodel.PHONE = DT2.Rows[0]["PHONE"].ToString();
pmodel.REGN_NO = DT2.Rows[0]["REGN_NO"].ToString();
pmodel.EMAIL = DT2.Rows[0]["EMAIL"].ToString();
pmodel.ADDRESS4 = DT2.Rows[0]["ADDRESS4"].ToString();
pmodel.ADDRESS3 = DT2.Rows[0]["ADDRESS3"].ToString();
pmodel.ADDRESS2 = DT2.Rows[0]["ADDRESS2"].ToString();
pmodel.ADDRESS1 = DT2.Rows[0]["ADDRESS1"].ToString();
SQL = " select RecordSource ,BillNo ,RecordNo,convert(varchar(11),RecordDt,106) as RecordDt,BillStatus,convert(varchar(11),BillDt,106) as BillDt,BillAmt,PayMode,ChequeNo,convert(varchar(11),ChequeDt,106) as ChequeDt from Tran_BillStatus where Party_Code='" + Session["user_ID"] + "' and Mines_Code='" + Session["mines"] + "' ";
pmodel.BillDT =DM.GetDataTable(SQL);
return View(pmodel);
}*/
....................................................................
As u see BillDT is the Datatable I am filling up and now i want to bind this to my Grid in my Html page. but the problem that I am facing is that as I am returning the model "pmodel" to the view and I am able to access and display all data but i cannot bind this datatable in the model "BillDT" to my Gridview. Kindly can u help me by showing the process in which a grid is bind with such datatable using MVC3 and razor tools.
Thank you