473,378 Members | 1,280 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

db grid display of duplicates

I have a question about how to display (or not to display) a column value that is same as the previous row.

For eg.
I have data in the database like this,

City Name Telephone
New York Abc 123434432
New York Xyz 321321312
Philly Raja 656567657
Philly Marice 343243434
I want to display this in a datagrid in such way that the output would be
City Name Telephone
New York Abc 123434432
Xyz 321321312
Philly Raja 656567657
Philly Marice 343243434
(note: for the row "Xyz" the city is 'blank', becasue it is same as the prevous row)

Hope you can help me do this.

Thanks in advance
Raja
Nov 18 '05 #1
2 1082
hi raja,

hi raja,

you may user datagrid itemcreated event.

if you are using a datatable you can get datatable row number by :

e.item.datasetindex

so if your datasource is DataTable MyTable;

then MyTable[e.Item.DataSetIndex] would return you the row that the grid is
rendering now.

and after you can check the value with the previos value with the value in
the MyTable[e.Item.DataSetIndex-1]

if they are same , you can hide text displayed.

for this ofcourse you may use a label control in a template to show city
column and after you can use a syntax like this :

((Label)e.Item.FindControl("lblCityName")).Visible =false;

regards,
ersin

"Raja" <Ra**@discussions.microsoft.com> wrote in message
news:F7**********************************@microsof t.com...
I have a question about how to display (or not to display) a column value that is same as the previous row.
For eg.
I have data in the database like this,

City Name Telephone
New York Abc 123434432
New York Xyz 321321312
Philly Raja 656567657
Philly Marice 343243434
I want to display this in a datagrid in such way that the output would be
City Name Telephone
New York Abc 123434432
Xyz 321321312
Philly Raja 656567657
Philly Marice 343243434
(note: for the row "Xyz" the city is 'blank', becasue it is same as the prevous row)
Hope you can help me do this.

Thanks in advance
Raja

Nov 18 '05 #2
Hi,

You can set the autogeneratecolumns property of the grid to false, then
create a manual itemtemplete for each columns. Then, for each itemtemplate,
mask it with your own serverside function as follows:-

<itemtemplate>
<%# checkcity(Container.DataItem("City"))%>
</itemtemplate>

in the codebehind, write a function checkcity as follows:-

Public Class Mypage

Public oldcity as string = ""
....
....

Private Function checkcity(Byval city as string)
If Len(oldcity) = 0 Then

oldcity = city
checkcity = city

Else
If oldcity.COmpare(city, oldcity) = 0 Then
oldcity = city
checkcity=""
Else
oldcity = city
checkcity=city
End IF
End If
End Function

End Class

Regards
Joyjit

"Raja" <Ra**@discussions.microsoft.com> wrote in message
news:F7**********************************@microsof t.com...
I have a question about how to display (or not to display) a column value that is same as the previous row.
For eg.
I have data in the database like this,

City Name Telephone
New York Abc 123434432
New York Xyz 321321312
Philly Raja 656567657
Philly Marice 343243434
I want to display this in a datagrid in such way that the output would be
City Name Telephone
New York Abc 123434432
Xyz 321321312
Philly Raja 656567657
Philly Marice 343243434
(note: for the row "Xyz" the city is 'blank', becasue it is same as the prevous row)
Hope you can help me do this.

Thanks in advance
Raja

Nov 18 '05 #3

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

Similar topics

1
by: Chris | last post by:
Hello, I'm new to .net development and I'm trying to develop a simple application that acts as a front end to a MS Access DB. The problem I have is that I am creating datasources via the...
0
by: J. Babe | last post by:
In my ASP.NET project I am creating an invoice. I add the items in my invoice to a datagrid (I'll call it dg). However, I am having some display issues. The following line should write "Total" in...
12
by: Kimberley Wiggins | last post by:
Can someone please help me? I am still learning vb so this is fairly new. I have been chasing this problem for 3 days now and I think that I am ready to give up. Does anyone know how to make...
117
by: phil-news-nospam | last post by:
Is there really any advantage to using DIV elements with float style properies, vs. the old method of TABLE and TR and TD? I'm finding that by using DIV, it still involves the same number of...
3
by: Chu | last post by:
Ok, my title may sound odd - let me explain what it means - It's easy to setup a grid to display 1 row of information per database record. Let's say this for example I have a grid display some...
0
by: bluesyt | last post by:
Greetings, I have never used grids before and I'm relatively new to VB. I am using VB6 and ADO to pull data from an SQL database. Everything works and I can get the data into the grid but when...
0
by: midussman | last post by:
I have an application that was originally developed in VB4 Pro, then upgraded to VB5. It uses the old VB4 MS Grid control (i.e. not been upgraded to the FlexGrid). Out of over 1000 users two have...
3
by: ryan.paquette | last post by:
In the table there are 2 fields in which I wish to limit (i.e. No Duplicates) Although I do not want to limit them to "No Duplicates" separately. I need them to be limited to "No Duplicates" as...
0
by: Rahul Metha | last post by:
o Select table from drop down list. o Display records in Grid – Display all records belong to table in grid. o Table Fields – This section will have all the fields which are belongs to table.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.