473,402 Members | 2,061 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,402 software developers and data experts.

Datagrid set field item to disply only when new

I have a data grid with about 20 repeating items. they
data:
colors, red
colors,blue
colors, green
Animals cat
animals bird
people, Tom
people, Bill
people, Kris
i want to have a level break so that THe first column will show only when
the "itemtype" is different from the previous. The data output as follows

Colors Red
Blue
green
Animals cat
bird
People
Tom
Bill
Kris

I'm not sure how to check for the first data value or where to check for it.
is there an "onChange" like event when the data isbound to the column?
I will post code if required, but i think this is a beginner/beginner
question for most of you. Note: i'm using VS.net and code behind.

Nov 19 '05 #1
4 1464
Kurt,

I would use the ItemDataBound event. Start off by setting a page level
variable to have an initial value of "". Then detect if the value of the
category is different than your variable. If it is, display the column value
and set the variable to the new value. If it isn't, you can set the cell
Text property to "" so that nothing shows.

Ian Suttle
http://www.IanSuttle.com
http://www.NewsFuel.com

"Kurt Schroeder" wrote:
I have a data grid with about 20 repeating items. they
data:
colors, red
colors,blue
colors, green
Animals cat
animals bird
people, Tom
people, Bill
people, Kris
i want to have a level break so that THe first column will show only when
the "itemtype" is different from the previous. The data output as follows

Colors Red
Blue
green
Animals cat
bird
People
Tom
Bill
Kris

I'm not sure how to check for the first data value or where to check for it.
is there an "onChange" like event when the data isbound to the column?
I will post code if required, but i think this is a beginner/beginner
question for most of you. Note: i'm using VS.net and code behind.

Nov 19 '05 #2
thanks for answering.
I think that's where i need to start, but i don't know how to reference the
data item.
i can get the index of the data item but how do i get the value of a
specific field:

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound

lblLabel1.Text = lblLabel1.Text & ", " & e.Item.ItemIndex

End Sub

here is the data grid:

<asp:DataGrid id="DataGrid1" runat="server" PageSize="3"
EnableViewState="False" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="typmainName"
Visible="false"></asp:BoundColumn>
<asp:BoundColumn DataField="typSubName"></asp:BoundColumn>
<asp:HyperLinkColumn Text="select" HeaderText="goto"
NavigateUrl="item.aspx?itmid="></asp:HyperLinkColumn>
<asp:BoundColumn DataField="itmID" ReadOnly="True"
HeaderText="ID"></asp:BoundColumn>
<asp:BoundColumn DataField="itmDesc3" ReadOnly="True"
HeaderText="Item"></asp:BoundColumn>
<asp:HyperLinkColumn DataTextField="itmDesc3"
DataNavigateUrlField="itmID"
DataNavigateUrlFormatString="item.aspx?itmid={0}&t ypmainIDX="
HeaderText="item"></asp:HyperLinkColumn>
<asp:TemplateColumn HeaderText="thisone">
<ItemTemplate>
<asp:HyperLink ID="itmID" Runat="server" NavigateUrl='<%#
"item.aspx?itmID=" & Container.DataItem("itmID") & "&MNTypID=" &
Container.DataItem("typmainIDX") %>'>go</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid></TD>
"Ian Suttle" wrote:
Kurt,

I would use the ItemDataBound event. Start off by setting a page level
variable to have an initial value of "". Then detect if the value of the
category is different than your variable. If it is, display the column value
and set the variable to the new value. If it isn't, you can set the cell
Text property to "" so that nothing shows.

Ian Suttle
http://www.IanSuttle.com
http://www.NewsFuel.com

"Kurt Schroeder" wrote:
I have a data grid with about 20 repeating items. they
data:
colors, red
colors,blue
colors, green
Animals cat
animals bird
people, Tom
people, Bill
people, Kris
i want to have a level break so that THe first column will show only when
the "itemtype" is different from the previous. The data output as follows

Colors Red
Blue
green
Animals cat
bird
People
Tom
Bill
Kris

I'm not sure how to check for the first data value or where to check for it.
is there an "onChange" like event when the data isbound to the column?
I will post code if required, but i think this is a beginner/beginner
question for most of you. Note: i'm using VS.net and code behind.

Nov 19 '05 #3
Kurt,

The the function argument "e" represents
System.Web.UI.WebControls.DataGridItemEventArgs and has access to the cells
collection. Try this to get or set the text:

strThing = e.Item.Cells(indexOfCell).Text

or

e.Item.Cells(indexOfCell).Text = "A Value"

Just be sure to specify what the cell index is instead of the indexOfCell
variable here.

Ian Suttle
http://www.IanSuttle.com
http://www.NewsFuel.com

"Kurt Schroeder" wrote:
thanks for answering.
I think that's where i need to start, but i don't know how to reference the
data item.
i can get the index of the data item but how do i get the value of a
specific field:

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound

lblLabel1.Text = lblLabel1.Text & ", " & e.Item.ItemIndex

End Sub

here is the data grid:

<asp:DataGrid id="DataGrid1" runat="server" PageSize="3"
EnableViewState="False" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="typmainName"
Visible="false"></asp:BoundColumn>
<asp:BoundColumn DataField="typSubName"></asp:BoundColumn>
<asp:HyperLinkColumn Text="select" HeaderText="goto"
NavigateUrl="item.aspx?itmid="></asp:HyperLinkColumn>
<asp:BoundColumn DataField="itmID" ReadOnly="True"
HeaderText="ID"></asp:BoundColumn>
<asp:BoundColumn DataField="itmDesc3" ReadOnly="True"
HeaderText="Item"></asp:BoundColumn>
<asp:HyperLinkColumn DataTextField="itmDesc3"
DataNavigateUrlField="itmID"
DataNavigateUrlFormatString="item.aspx?itmid={0}&t ypmainIDX="
HeaderText="item"></asp:HyperLinkColumn>
<asp:TemplateColumn HeaderText="thisone">
<ItemTemplate>
<asp:HyperLink ID="itmID" Runat="server" NavigateUrl='<%#
"item.aspx?itmID=" & Container.DataItem("itmID") & "&MNTypID=" &
Container.DataItem("typmainIDX") %>'>go</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid></TD>
"Ian Suttle" wrote:
Kurt,

I would use the ItemDataBound event. Start off by setting a page level
variable to have an initial value of "". Then detect if the value of the
category is different than your variable. If it is, display the column value
and set the variable to the new value. If it isn't, you can set the cell
Text property to "" so that nothing shows.

Ian Suttle
http://www.IanSuttle.com
http://www.NewsFuel.com

"Kurt Schroeder" wrote:
I have a data grid with about 20 repeating items. they
data:
colors, red
colors,blue
colors, green
Animals cat
animals bird
people, Tom
people, Bill
people, Kris
i want to have a level break so that THe first column will show only when
the "itemtype" is different from the previous. The data output as follows

Colors Red
Blue
green
Animals cat
bird
People
Tom
Bill
Kris

I'm not sure how to check for the first data value or where to check for it.
is there an "onChange" like event when the data isbound to the column?
I will post code if required, but i think this is a beginner/beginner
question for most of you. Note: i'm using VS.net and code behind.

Nov 19 '05 #4
thanks!!
kes

"Ian Suttle" wrote:
Kurt,

The the function argument "e" represents
System.Web.UI.WebControls.DataGridItemEventArgs and has access to the cells
collection. Try this to get or set the text:

strThing = e.Item.Cells(indexOfCell).Text

or

e.Item.Cells(indexOfCell).Text = "A Value"

Just be sure to specify what the cell index is instead of the indexOfCell
variable here.

Ian Suttle
http://www.IanSuttle.com
http://www.NewsFuel.com

"Kurt Schroeder" wrote:
thanks for answering.
I think that's where i need to start, but i don't know how to reference the
data item.
i can get the index of the data item but how do i get the value of a
specific field:

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound

lblLabel1.Text = lblLabel1.Text & ", " & e.Item.ItemIndex

End Sub

here is the data grid:

<asp:DataGrid id="DataGrid1" runat="server" PageSize="3"
EnableViewState="False" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="typmainName"
Visible="false"></asp:BoundColumn>
<asp:BoundColumn DataField="typSubName"></asp:BoundColumn>
<asp:HyperLinkColumn Text="select" HeaderText="goto"
NavigateUrl="item.aspx?itmid="></asp:HyperLinkColumn>
<asp:BoundColumn DataField="itmID" ReadOnly="True"
HeaderText="ID"></asp:BoundColumn>
<asp:BoundColumn DataField="itmDesc3" ReadOnly="True"
HeaderText="Item"></asp:BoundColumn>
<asp:HyperLinkColumn DataTextField="itmDesc3"
DataNavigateUrlField="itmID"
DataNavigateUrlFormatString="item.aspx?itmid={0}&t ypmainIDX="
HeaderText="item"></asp:HyperLinkColumn>
<asp:TemplateColumn HeaderText="thisone">
<ItemTemplate>
<asp:HyperLink ID="itmID" Runat="server" NavigateUrl='<%#
"item.aspx?itmID=" & Container.DataItem("itmID") & "&MNTypID=" &
Container.DataItem("typmainIDX") %>'>go</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid></TD>
"Ian Suttle" wrote:
Kurt,

I would use the ItemDataBound event. Start off by setting a page level
variable to have an initial value of "". Then detect if the value of the
category is different than your variable. If it is, display the column value
and set the variable to the new value. If it isn't, you can set the cell
Text property to "" so that nothing shows.

Ian Suttle
http://www.IanSuttle.com
http://www.NewsFuel.com

"Kurt Schroeder" wrote:

> I have a data grid with about 20 repeating items. they
> data:
> colors, red
> colors,blue
> colors, green
> Animals cat
> animals bird
> people, Tom
> people, Bill
> people, Kris
> i want to have a level break so that THe first column will show only when
> the "itemtype" is different from the previous. The data output as follows
>
> Colors Red
> Blue
> green
> Animals cat
> bird
> People
> Tom
> Bill
> Kris
>
> I'm not sure how to check for the first data value or where to check for it.
> is there an "onChange" like event when the data isbound to the column?
> I will post code if required, but i think this is a beginner/beginner
> question for most of you. Note: i'm using VS.net and code behind.
>

Nov 19 '05 #5

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

Similar topics

3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
1
by: Jeremy | last post by:
I want my gird to sort only the items on the current page when I click on a column header. I wrote a little test app, but when I sort it pulls in items from other pages and places them on the current...
1
by: Harry Devine | last post by:
I have a DataGrid that is configured to use the Edit/Update/Cancel concept correctly. My grid shows values from 5 database fields. I only need to update that last 4 fields. The last field is a...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
0
by: Nathan Franklin | last post by:
Hello Guys, I have been trying to work this our for so long, but I just can't seem to find the answer. I am loading a datatable from a an access database using an oledbdataadapter. I then...
13
by: shookim | last post by:
I don't care how one suggests I do it, but I've been searching for days on how to implement this concept. I'm trying to use some kind of grid control (doesn't have to be a grid control, whatever...
5
nmm32
by: nmm32 | last post by:
I have a DataGrid which displays data with the aid of a procedure. I have tested the procedure inside the database and it is working fine. I have another procedure which adds another row to the...
0
by: cms3023 | last post by:
I have a DataGrid which displays data with the aid of a procedure. I have tested the procedure inside the database and it is working fine. The table inside the database has data that matches with...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...

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.