Hi,
I have need to perform a sql on the following tables:
Order
------
order_id
order_date
cust_id
Order_Items
---------------
Order_id
item_id
so I have the following linqtosql:
var query = from o in dc.order
select new
{
OrderId = o.order_id,
OrderDate = o.order_date,
CustId = o.cust_id,
items = (from oi in dc.Order_Items
where oi.order_id == o.orderId
select new { oi.item_id}),
}
Gridview1.DataSource = query;
Gridview1.DataBind();
I plan to have this query in gridview, suppressing repeating columns[orderid, orderdate, custid] if there are multiple items for that order. Can anyone tell me how to code the mark-up tags so that the Gridview1 items column can display the items collection? This is what I have so far:
<asp:GridView ID="GridView1" runat="server" UseAccessibleHeader="True"
DataKeyNames="OrderId" SelectedIndex="1"
AutoGenerateColumns="False" AllowPaging="True" AllowSorting="True" PageSize="50">
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="OrderId"
DataNavigateUrlFormatString="OrderAdd.aspx?update=true&orderid={0}"
DataTextField="OrderId" NavigateUrl="OrderAdd.aspx" HeaderText="OrderId" SortExpression="OrderId" />
<asp:boundfield datafield="OrderDate" readonly="true" headertext="OrderDate"/>
<asp:TemplateField HeaderText="items" SortExpression="items">
<ItemTemplate>
<asp:ListBox ID="ListBox1" runat="server" DataTextField="items" DataValueField="items" DataSource="items"></asp:ListBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Thanks for your input!
Best,
TinaC
I have need to perform a sql on the following tables:
Order
------
order_id
order_date
cust_id
Order_Items
---------------
Order_id
item_id
so I have the following linqtosql:
var query = from o in dc.order
select new
{
OrderId = o.order_id,
OrderDate = o.order_date,
CustId = o.cust_id,
items = (from oi in dc.Order_Items
where oi.order_id == o.orderId
select new { oi.item_id}),
}
Gridview1.DataSource = query;
Gridview1.DataBind();
I plan to have this query in gridview, suppressing repeating columns[orderid, orderdate, custid] if there are multiple items for that order. Can anyone tell me how to code the mark-up tags so that the Gridview1 items column can display the items collection? This is what I have so far:
<asp:GridView ID="GridView1" runat="server" UseAccessibleHeader="True"
DataKeyNames="OrderId" SelectedIndex="1"
AutoGenerateColumns="False" AllowPaging="True" AllowSorting="True" PageSize="50">
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="OrderId"
DataNavigateUrlFormatString="OrderAdd.aspx?update=true&orderid={0}"
DataTextField="OrderId" NavigateUrl="OrderAdd.aspx" HeaderText="OrderId" SortExpression="OrderId" />
<asp:boundfield datafield="OrderDate" readonly="true" headertext="OrderDate"/>
<asp:TemplateField HeaderText="items" SortExpression="items">
<ItemTemplate>
<asp:ListBox ID="ListBox1" runat="server" DataTextField="items" DataValueField="items" DataSource="items"></asp:ListBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Thanks for your input!
Best,
TinaC