473,795 Members | 3,167 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to mark first occurence of value in a datagrid?

This should be an easy match, but I'm lost. I want to perform a kind
of grouping of the data in a datagrid object, so that only the first
occurrence of a value in column one is visible. The following equal
rows should be blanked in column one, se example:

Col.one Col.two Col.three
A Data1 DataA1
Data2 DataA2
Data3 DataA3
B Data1 DataB1
Data2 DataB2

etc...

I'm trying to do this in the ItemCreated event, but I'm not able to
compare the current row with the previous. Or store the previous value
in some variable.. Please help, it's getting late!

Regards,
John Martin
Nov 17 '05 #1
1 1382
SSW
Hi,

Declare Dummy as string at Page level. Comapre each columns values with
Dummy. If same then Set cell value as "" else set the Dummy variable with
Cell value.

Hope code below will help.

Thanks,

SSW
MCSD, MCAD, OCA
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----

Code Begin
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----
private string Dummy;//Class level variable
private void dgURGrid_ItemDa taBound(object sender,
System.Web.UI.W ebControls.Data GridItemEventAr gs e)
{
int i = 0;
if (e.Item.ItemTyp e.ToString() !="Header")
{
if(e.Item.DataI tem !=null)
{
DataGridItem di = new DataGridItem(e. Item.ItemIndex,
e.Item.DataSetI ndex, ListItemType.Se parator);
if(Dummy!=e.Ite m.Cells[i].Text)
Dummy = e.Item.Cells[i].Text;
else
e.Item.Cells[i].Text = "";
}
}
}
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----

Code End
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----

"John Martin" <jm*@larvikbank en.no> wrote in message
news:f8******** *************** ***@posting.goo gle.com...
This should be an easy match, but I'm lost. I want to perform a kind
of grouping of the data in a datagrid object, so that only the first
occurrence of a value in column one is visible. The following equal
rows should be blanked in column one, se example:

Col.one Col.two Col.three
A Data1 DataA1
Data2 DataA2
Data3 DataA3
B Data1 DataB1
Data2 DataB2

etc...

I'm trying to do this in the ItemCreated event, but I'm not able to
compare the current row with the previous. Or store the previous value
in some variable.. Please help, it's getting late!

Regards,
John Martin

Nov 17 '05 #2

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

Similar topics

1
3942
by: Roland | last post by:
hi all having designed my schema to use repeating groups of elements, I found that some applications (eg. Microsoft InfoPath) refused to recognised that element as a repeating element. I subsequently found that out of the three possible ways (that I know of) of declaring repeating elements in xsd, only one of these was understood:
0
1297
by: Gidi | last post by:
Hi, I have DataGrid table and TextBox in my form. the table contains names and i use the textBox to enter letters to search specific customer. i want that the user will be able to navigate the DataGrid with the UP and Down arrows while the focus is on the TextBox and to mark the selected row. for example, when the form loads,the focus is on the Textbox and the first row is marked, the textbox is empty. i enter G and the table contains...
4
1298
by: Gidi | last post by:
Hello, I have a dataGrid that contains customers details, i made an event that when the DataGrid is loaded the first row is marked or when some row is clicked this row is marked, how can i do that when the user uses the Up and Down arrows, it will mark the row that the user is on now. i tried to use the key event but it wasn't good. is there any other way to do it? or if that's the only way how can i do it right? I looked at the...
3
3463
by: danc | last post by:
I have a datagrid with a checkbox and dropdown list in each row. Both set AutoPostBack to true and ItemCommand and OnSelectedIndexChanged events for these controls works fine when DataGrid is not paged. As soon as I turn on paging support, I no longer get events properly for any page except the first. 1) The DataGrid displays the page numbers on the top (and bottom). Whenever I click to go to a specific page number, the DropDownList's...
1
11923
by: hairlessOrphan | last post by:
Hi! Is there any way to get the Replace() function in MSSQL to replace only the first occurence of a substring? For example, my Name column has the following data: Bob BobBob And I want to replace "Bob" with "Robert," but *only* the first occurence: Robert
7
3350
by: mike.aldrich | last post by:
Hi folks, I am trying to read the first occurence of non-whitespace in a file, within a zipfile. Here is my code: zipnames = glob.glob("<search_dir>*") for zipname in zipnames: z = zipfile.ZipFile(zipname, "r") for filename in z.namelist(): count = len(z.read(filename).split('\n')) if fnmatch.fnmatch(filename, "*AUDIT*"):
4
3960
by: mercuryshipzz | last post by:
Hi, My objective is to get the line number of the first occurance of the search pattern. my test.txt contains: ..... .................. total rows.... ................... ..
2
1685
chathura86
by: chathura86 | last post by:
hi i got the following error when i was working with a datagrid i tried to bind a value to a text box in datagrid <asp:TemplateColumn HeaderText="PRICE" ItemStyle-HorizontalAlign="Center"> <ItemTemplate>
6
1938
by: tshad | last post by:
I have a filename that I want to extract the 1st set of numbers up to either a ".", "-", "_" or "~" and make that an int. Or I guess easier just take all the values that are 0-9 up to the 1st non number value. So that if I have a value 449231.xml or 449231~1.xml or 449231-1a.xml, I want to get the 449231 only and make that an integer. Can that be done in one statement?
0
9672
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
10435
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...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9037
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...
0
5436
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
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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.