1
Answer

how to bind a web grid to a data source

swati

swati

8y
386
1

Hello everyone m facing difficulty in binding my we grid in view to datasource through my controller action here is my code :

 Model:

public DataContext()

: base("conn")

{

}

public DbSet<GeshaftPartner> geschaftPartner { get; set;}

 
View:

@{

var grid = new WebGrid(Model);

grid.GetHtml(columns:grid.Columns(grid.Column("PartnerName1","Name",canSort :true),

grid.Column("AnSchriftOrt","Ort")));

}

 

CONTROLLER:

public ActionResult ShowSelectedPartnerGrid_EF(string partnerID)

{

DataContext db = new DataContext();

var strQuery = "select PartnerName1,AnSchriftOrt from db.geschaftPartner =" + partnerID;

return View(strQuery.AsEnumerable());

 
The "partnerID" I am getting from another view ..based on this partnerID I want to fetch the row from my DataBase and show it in the grid
 
any suggestions are really appreciated.. thanx in advance 



           

           

       

 



       

 
 

Answers (1)