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

Home Posts Topics Members FAQ

Can i have a Row Counter in a Bounded DataGrid?

RSB
Hi I Want to Bind the DataGrid with the Collection i have and want to
display a RowCounter 1,2,3,4,... in the First Column.. how to Do this??
Does Datagrid Provides any property etc.etc.??

Thank You

RSB
Nov 18 '05 #1
2 877
A sneaky way is to databind to a protected int with an increment operator:

<templatecolumn etc..> <%#i++%> </...>

Each time the integer is accessed by the databinding code it increments by
one, which produces the desired effect.

rath.

"RSB" <rs*****@hotmail.com> wrote in message
news:7H*****************@news.cpqcorp.net...
Hi I Want to Bind the DataGrid with the Collection i have and want to
display a RowCounter 1,2,3,4,... in the First Column.. how to Do this??
Does Datagrid Provides any property etc.etc.??

Thank You

RSB

Nov 18 '05 #2
"RSB" <rs*****@hotmail.com> wrote in message
news:7H*****************@news.cpqcorp.net...
Hi I Want to Bind the DataGrid with the Collection i have and want to
display a RowCounter 1,2,3,4,... in the First Column.. how to Do this??
Does Datagrid Provides any property etc.etc.??


The ItemDataBound event of the DataGrid will be raised once per row in the
grid. You can use the EventArgs to get access to the Item being bound, and
therefore, to the ItemIndex:

private void myGrid_ItemDataBound(object sender, DataGridItemEventArgs e)
{
// e.Item.ItemIndex is the index of the item being DataBound
}

You could add a TemplateColumn as your first column, and it could contain a
Label control. You could set the text of the label to ItemIndex.
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #3

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

Similar topics

1
by: Ux | last post by:
ServerSide: PHP+MySql ClientSide: JS (IE5+, Moz1.7) I need to edit an HTML table that contains records from a table in MySQL. A MsAccess datagrid or similar behaviour should be the best, but...
3
by: Vikramaditya Singh | last post by:
i want to show a serial no column in a data grid which is bounded to a data table. Is it possible. does datagrid has some property to do this
1
by: basulasz | last post by:
May be it is a bit easy question but i don't know the way to display data in bounded colums. I get data from DB with a datareader, and I want to display them on bounded colums. I dont want to...
7
by: GabyFont | last post by:
Hi, I'm new to Access so excuse if my question is too simple. I'm creating an app to manage spare objects in my company. So a user select from list boxes the criteria they want and hit a button...
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...
1
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
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
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
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 ...

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.