473,473 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Referencing Dataset row not Datagrid row

How do I reference the dataset row number for the data in the datagrid and
not the datagrid row itself when calling a function from the HTML?

When I am calling a function from a datagrid column as shown below I can use
'Container.ItemIndex' which refers to datagrid row number but I want the row
number of the dataset. If you implement paging then the row number of the
first row is the same no matter what page you are on which is not what I
want.

In some events I believe it is e.item.itemindex that refers to the row
number of the dataset but I need to pass it from the HTML.

<asp:TemplateColumn HeaderText="FYC Potential">
<ItemTemplate>
<asp:Label id="Label2" runat="server" Text='<%#
fDetermineFYC(Container.ItemIndex) %>'>lblFYCPotential</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
Nov 18 '05 #1
2 1164
Someone might have a better suggestion, but you could always add an
autoincrementing datacolum to your table,

DataSet ds = getMyDataSet()
DataColumn dc = new DataColumn("RowId", typeof(System.Int32));
dc.AutoIncrement = true;
dc.AutoIncrementSeed = 1;
dc.AutoIncrementStep = 1;
ds.Tables[0].Columns.Add(dc);

And you can then using DataBinder.Eval(Container.DataItem, "RowId")

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Craig" <Cr**********@hotmail.com> wrote in message
news:eT**************@tk2msftngp13.phx.gbl...
How do I reference the dataset row number for the data in the datagrid and
not the datagrid row itself when calling a function from the HTML?

When I am calling a function from a datagrid column as shown below I can use 'Container.ItemIndex' which refers to datagrid row number but I want the row number of the dataset. If you implement paging then the row number of the
first row is the same no matter what page you are on which is not what I
want.

In some events I believe it is e.item.itemindex that refers to the row
number of the dataset but I need to pass it from the HTML.

<asp:TemplateColumn HeaderText="FYC Potential">
<ItemTemplate>
<asp:Label id="Label2" runat="server" Text='<%#
fDetermineFYC(Container.ItemIndex) %>'>lblFYCPotential</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

Nov 18 '05 #2
Craig, you could also "do the math" (e.g. page #x, y items per page, etc.)

"Craig" wrote:
How do I reference the dataset row number for the data in the datagrid and
not the datagrid row itself when calling a function from the HTML?

When I am calling a function from a datagrid column as shown below I can use
'Container.ItemIndex' which refers to datagrid row number but I want the row
number of the dataset. If you implement paging then the row number of the
first row is the same no matter what page you are on which is not what I
want.

In some events I believe it is e.item.itemindex that refers to the row
number of the dataset but I need to pass it from the HTML.

<asp:TemplateColumn HeaderText="FYC Potential">
<ItemTemplate>
<asp:Label id="Label2" runat="server" Text='<%#
fDetermineFYC(Container.ItemIndex) %>'>lblFYCPotential</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

Nov 18 '05 #3

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

Similar topics

4
by: Steve Donnor | last post by:
Here's my question.. I have a Dataset which has populated a datagrid with information from an AS400 That SQL looks like this "Select MASYS, MAFLD, MADATA, MAEQV from QS36F.MAPDATA WHERE MASYS =...
0
by: Frosty | last post by:
Hi I am using the VS xsd designer to create a strongly typed dataset. The dataset is apparently successfully created, with no warnings or errors given. Is it not then to be expected that this...
3
by: Diego TERCERO | last post by:
Hi... I'm working on a tool for editing text resources for a family of software product my company produces. These text resources are found in a SQL Server database, in a table called...
1
by: Krzysztof Karnicki | last post by:
I have such a problem… I have create my custom DataGridColumn inheriting from System.Windows.Forms.DataGridColumnStyle on using it on DataGrid, to show rows painted by me self. Because dates ...
2
by: Alpha | last post by:
Hi, I have a window based program. One of the form has several textboxes and a datagrid. The textboxes are bind to the same dataset table as the datagrid and the text changes to reflect different...
3
by: Ben Becker | last post by:
I am trying to build a custom crosstab type of grid where I take some items in a data grid and based on the content of the current item compared to the previous item, determine if a new row in a...
3
by: Lyners | last post by:
I have a table within a cell of a datagrid. I am doing updates without postback to the server using Javascript. I have everything working, except referencing a table within the datagrid cell. ...
3
by: Datatable Dataset Datagrid help | last post by:
Hi I am somewhat confused, I am new at VB.net I use XML data, I have a datagrid, I created a datatable so that I can create a custom format like true is this graphic false is this graphic and...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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...

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.