473,837 Members | 1,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Urgent please

Hi,

I need to merge the rows in the datagrid based on the condition.Pleas e
let me know how can i do that.Here is the scenario:

Present View:

Short name Filed by
A P
A Q
A R
B S
B T
B U
C V
C W

But i need to display like this:
Short Name Filed By
A P,Q,R
B S,T,U
C V,W

For that i used itemtemplate in the grid control as below:

<asp:datagrid id="grdRegister " Runat="server"
OnPageIndexChan ged="NewPage" Headerstyle-BackColor="#9B9 BB4"
Width="100%" HeaderStyle-Font-Bold="True"
HeaderStyle-ForeColor="#000 000" HeaderStyle-CssClass="table header"
AutoGenerateCol umns="False"
Font-Name="verdana">
<AlternatingIte mStyle BackColor="#e2e 2e2" Font-Name="verdana"
/>
<Columns>
<asp:BoundColum n DataField="Shor t/Long Entry"
HeaderText="Sho rt/Long Entry" />

<asp:TemplateCo lumn HeaderText="Fil ed by">
<ItemTemplate >
<asp:Label runat="server" Text='<%# string.Format( "{0},
{1}",
DataBinder.Eval (Container, "DataItem.F iled By"),
DataBinder.Eval (Container, "DataItem.S hort/Long Entry") ) %>'
ID="Label4">
</asp:Label>
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:datagrid>
Please let me know how can i achieve that.

Thanks,
Vishnu

Nov 10 '06 #1
1 1520
Hi,

You need to create a new DataTable and use it as data source for
GridView:

DataTable table = new DataTable("tabl e");
DataColumn colShortName = new DataColumn("Sor tName",
Type.GetType("S ystem.String")) ;
table.Columns.A dd(colShortName );
DataColumn colFiledBy = new DataColumn("Fil edBy",
Type.GetType("S ystem.String")) ;
table.Columns.A dd(colFiledBy);

// here you need to inerate through all rows in your dataset or
whatever you get from the database

foreach (DataRow row in ...) {
DataRow[] rows = table.Select("S hortName = '" + row["ShortName"] +
"'");
if (rows.Count 0) {
DataRow r = rows[0];
r["FiledBy"] += ", " + row["FiledBy"];
} else {
DataRow newRow = table.NewRow();
newRow["ShortName"] = row["ShortName"];
newRow["FiledBy"] = row["FiledBy"];
table.Rows.Add( newRow);
}
}

grdRegister.Dat aSource = table;
grdRegister.Dat aBind();

Alexander Kleshchevnikov
www.klalex.com

"""se****@gmail .com ÐÉÓÁÌ(Á):
"""
Hi,

I need to merge the rows in the datagrid based on the condition.Pleas e
let me know how can i do that.Here is the scenario:

Present View:

Short name Filed by
A P
A Q
A R
B S
B T
B U
C V
C W

But i need to display like this:
Short Name Filed By
A P,Q,R
B S,T,U
C V,W

For that i used itemtemplate in the grid control as below:

<asp:datagrid id="grdRegister " Runat="server"
OnPageIndexChan ged="NewPage" Headerstyle-BackColor="#9B9 BB4"
Width="100%" HeaderStyle-Font-Bold="True"
HeaderStyle-ForeColor="#000 000" HeaderStyle-CssClass="table header"
AutoGenerateCol umns="False"
Font-Name="verdana">
<AlternatingIte mStyle BackColor="#e2e 2e2" Font-Name="verdana"
/>
<Columns>
<asp:BoundColum n DataField="Shor t/Long Entry"
HeaderText="Sho rt/Long Entry" />

<asp:TemplateCo lumn HeaderText="Fil ed by">
<ItemTemplate >
<asp:Label runat="server" Text='<%# string.Format( "{0},
{1}",
DataBinder.Eval (Container, "DataItem.F iled By"),
DataBinder.Eval (Container, "DataItem.S hort/Long Entry") ) %>'
ID="Label4">
</asp:Label>
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:datagrid>
Please let me know how can i achieve that.

Thanks,
Vishnu
Nov 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1640
by: learner | last post by:
Hi, In a page, i have many links. I have some functions in a global file which is included in all linked pages. I want to have a reference to a window which is to be opened on clicking one link and it should be known only to one more link on that page and not to other links. I cant have that window reference in that global file, since iam declaring it initially as Null and modifying its value in that one particular link. Since all links...
2
1604
by: Dimitri | last post by:
PLEASE HELP,I HAVE A DATABSE WITH MULTIPLE RECORDS AS OUTLINED BELOW EMP NO LEVEL NEXTINCREASE WAGETYPE UNIT 1000 1 0 1000 1000 1 0 1002 1 I WANT TO BE TO HAVE THIS IN ONE RECORD IE REPEAT THE COULUMNS WAGETYPE AND UNIT(APPEND THEM TO THE END OF UNIT)
28
3078
by: Tamir Khason | last post by:
Follwing the struct: public struct TpSomeMsgRep { public uint SomeId;
0
1306
by: Charles Dido | last post by:
Sir, I am MR.CHARLES ALAMIEYESEIGHA. I am the son of GOVONOUR of BAYELSA STATE IN NIGERIA.Some months ago, this YEAR, my father was arrested in LONDON by the LONDON METHROPOLITAN POLICE for money laundering.My father MR. D.S.P.ALAMIEYESEIGHA was accussed of embezzling the <The sum of FOURTY FIVE MILLION DOLLARS>. Since my father"s arrest i have been able to set aside the sum of nine million dollars.This money is meant to be used to...
17
2295
by: Saps | last post by:
Hi all. Can anyone help me here. I have loads of .sql files and i need a way to call these from my asp page so the user can run them from the browser. Meaning i have a page with a list of all scripts. each when clicked i am able to run the script. so HOW and what do i do to call and run the .sql Thanks
3
6485
by: N. Spiker | last post by:
I am attempting to receive a single TCP packet with some text ending with carriage return and line feed characters. When the text is send and the packet has the urgent flag set, the text read from the socket is missing the last character (line feed). When the same text is sent without the urgent flag set, all of the characters are read. I'm reading the data using the blocking read call of the network stream class. The .NET...
4
2964
by: Adrian Parker | last post by:
We've suddenly started getting a problem with a call to clear the contents of a DataTable. This is on a live customer site that's been working fine until yesterday. As far as we know they've not changed or updated the server in any way. "There is no row at position 42" at System.Data.RBTree`1.GetNodeByIndex(int32 userIndex) at System.Data.DataTable.Clear(Boolean clearAll) at system.Data.DataTable.Clear()
5
4762
by: igotyourdotnet | last post by:
I'm creating a web service this is going to return an arraylist of items. When I try and run it Im' getting the following error message: System.InvalidOperationException: There was an error generating the XML document. ---System.InvalidOperationException: The type Car List was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically. at...
4
1921
by: ashasivan | last post by:
Hi, Please help me as soon as possible for the following problem. It is very very urgent. I have an XML file as follows: <?xml version="1.0" standalone="yes"?> <Employee> <em name="Asha" id="1"> <details>456</details>
1
2126
by: psantosh12 | last post by:
Hello Frnds Please need help to resolve error.......... it is very very urgent........ The error is Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. Details: To enable the details of...
0
9851
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10902
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10583
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9420
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7824
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5680
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4060
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3128
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.