How to don't display value?

L

Leszek

I wrote an aspx page.
It shows datagrid with values:

server | parameter
---------------------
server1 | parameter1
server1 | parameter2
server1 | parameter3
server1 | parameter4
server1 | parameter5
server2 | parameter1
server2 | parameter2
server2 | parameter6
server3 | parameter3
server3 | parameter7
server3 | parameter13
server3 | parameter34

I'm trying to do something like that:
server | parameter
---------------------
server1 | parameter1
| parameter2
| parameter3
| parameter4
| parameter5
server2 | parameter1
| parameter2
| parameter6
server3 | parameter3
| parameter7
| parameter13
| parameter34

Can someone make a hint/help/anything, how can i do that?
 
E

Eliyahu Goldin

In PreRender event handler loop through the grid records. Every loop
remember server column value. If the next iteration the value is the same,
replace it with empty string.

Eliyahu
 
J

Jeppe Dige Jespersen

Can someone help me?

I think so. :)

What you can do is use two datagrids. One inside the other. In my example, I
have a grid (datagrid1) with customers in it. For each customer, I want to
display the orders for THAT customer.

Inside a "template column" in the customer grid, I have another grid
(datagrid2). The datasource for the Customers datagrid is the Customers
datatable in in my dataset. The datasource for the order grid, is a function
that returns the orders for THAT customer.

The HTML looks like this:

<asp:DataGrid id=DataGrid1 runat="server" DataSource="<%# ds %>"
DataMember="Customers" Height="88px" Width="376px"
AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="CustomerID" SortExpression="CustomerID"
HeaderText="CustomerID"></asp:BoundColumn>
<asp:BoundColumn DataField="CompanyName" SortExpression="CompanyName"
HeaderText="CompanyName"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Orders">
<ItemTemplate>
<asp:DataGrid id=DataGrid2 runat="server" DataSource='<%#
getOrders(container.dataitem("CustomerID")) %>' AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="OrderID" SortExpression="OrderID"
HeaderText="OrderID"></asp:BoundColumn>
<asp:BoundColumn DataField="OrderDate" SortExpression="OrderDate"
HeaderText="OrderDate"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>

The getOrders function is in my codebehind file. The codebehind contains two
functions: The Page_Load eventhandler, and the getOrders function. The
codebehind looks like this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
daCustomers.Fill(ds, "Customers")
daOrders.Fill(ds, "Orders")
DataGrid1.DataBind()
End Sub

Public Function getOrders(ByVal custid As String) As DataRow()
Return ds.Orders.Select("CustomerID ='" & custid & "'")
End Function

Hope this can help you out.

Jeppe Jespersen
 
L

Leszek

Thank you for your help! :)
Now i know, how can i do this in VB.NET

But maybe there is more short and faster solution for this?
Maybe simple SQL query?
I thought about "TOP" function. But i cannot use it. (I don't know how).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,087
Members
48,773
Latest member
Kaybee

Latest Threads

Top