Referencing Dataset row not Datagrid row

C

Craig

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>
 
K

Karl Seguin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top