My coding here
index.cshtml
@{
var db = Database.Open("EduCon");
var selectQueryString = "select firstname,lastname,emailaddress from person2";
var data = db.Query(selectQueryString);
var grid1 = new WebGrid(source: data,
defaultSort: "firstname",
rowsPerPage: 5,
sortFieldName:"firstname"
);
@grid1.GetHtml(
tableStyle: "grid",
headerStyle: "head",
alternatingRowStyle: "alt",
columns: grid1.Columns(
grid1.Column("firstname", format: @@item.firstname),
grid1.Column("lastname", format: @@item.lastname),
grid1.Column("emailaddress", format: @[email protected] )
)
)
10 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Iftikar HussainPosted Jul 19, 2013, 7:05 AM
in your cshtml
columns:ViewBag.Columns
Regards,
Iftikar
vidhyaPosted Jul 19, 2013, 6:20 AM
Iftikar HussainPosted Jul 19, 2013, 6:18 AM
Regards,
Iftikar
vidhyaPosted Jul 19, 2013, 6:14 AM
If i use this from the above
grid1.Column("marks", format: @@item.marks)
I am getting the error:
'System.Web.Helpers.WebGridRow' does not contain a definition for 'marks'
vidhyaPosted Jul 19, 2013, 6:12 AM
This is my stored procedure output
create,cost,analysis,create,new are assignmentname how do i assign in grid
Iftikar HussainPosted Jul 19, 2013, 4:57 AM
Regards,
Iftikar
vidhyaPosted Jul 19, 2013, 4:14 AM
this is my index.cshtml file
Here i used sql query (which i bolded).
Instead of the sql query i need to use my procedurename.
Iftikar HussainPosted Jul 19, 2013, 3:46 AM
Regards,
Iftikar
vidhyaPosted Jul 19, 2013, 3:32 AM
directly i need to use storedprocedure. from the above example i used directly sql statement like that i need to use stored procedure.
Iftikar HussainPosted Jul 19, 2013, 3:09 AM
Are using EntityFramework or LINQ to SQL?
Regards,
Iftikar