2
Answers

LinQ binding to Gridview

Hi,

I know by using we can bind the table to gridview like this:

dataGridView1.DataSource=( from customer in db.Customers
where customer.Country == "USA"
orderby customer.CompanyName
select new { customer.CustomerID,
customer.City }).ToBindingList();

In this case can we declare the gridview in aspx page with

<asp:TemplateField HeaderText="Title">

<ItemTemplate>

&nbsp;<asp:LinkButton ID="lbTitle" runat="server" CommandArgument="<%# Container.DisplayIndex %>" CommandName="Link" Text='<%# DataBinder.Eval (Container.DataItem, "city") %>'

></asp:LinkButton>

</asp:templatefield>

can we do like this in aspx page.

Thanks

Answers (2)