infobih
Posts: 58
|
| Posted: 01/17/2010, 2:15 PM |
|
Sorry, maybe this question is dumb, but i can't figure how to generate auto increment number for each row in Grid automatically.
Format:
1 data
2 data
3 data
etc
How to properly use function count()
Thanks a lot.
|
 |
 |
damian
Posts: 838
|
| Posted: 01/17/2010, 3:38 PM |
|
what database are you using - easiest way is to set the primary key to auto-increment in the database....
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
infobih
Posts: 58
|
| Posted: 01/17/2010, 11:02 PM |
|
Damian thank you
I use MySQL database, but I have correctly set primary key auto-increment in the database. What I need is to generate on the fly counter for each row (Label control) in a row like
1,2,3..... not depending what actual ID primary key is
Thanks again
|
 |
 |
rho
Posts: 85
|
| Posted: 01/17/2010, 11:30 PM |
|
This can be done using a label and a counter. For example:
First put
$rowcounter = 0;
on top of your page
Then, in the grid's BeforeShowRow Event, increment the counter:
$rowcounter+=1;
And then set your counter label to the counter value:
$sender->lblCounter->SetValue($rowcounter);
Hope this helps,
Rob.
|
 |
 |
infobih
Posts: 58
|
| Posted: 01/18/2010, 1:41 AM |
|
Thanks Rob
I tried this, but had problem because in my case it is "Editable Grid" from "Order Entry" Example Pack de CodeCharge and I have already Events in "Before Row Show".
Don't work
|
 |
 |
rho
Posts: 85
|
| Posted: 01/18/2010, 1:54 AM |
|
For the code to be entered, you have to create "Custom Code" on the BeforeShowRow event...
|
 |
 |
damian
Posts: 838
|
| Posted: 01/18/2010, 1:29 PM |
|
look at this example:
http://forums.codecharge.com/posts.php?post_id=68718&s_keyword=alt+row
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |