468,457 Members | 1,756 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,457 developers. It's quick & easy.

Causing events to fire in a datagrid

I finally learned that
DataGrid1.EditItemIndex = {row I want} -1
DataGrid1.DataBind()

will make that row get to edit mode.
I am stiil looking for ways to programticaly do other things:
1) show the last page
2) fire select
3) fire delete
4) what is the last row in the last page

Thanks!
Nov 19 '05 #1
2 1306
Hi Ofer,

1) Show the last page

DataGrid1.CurrentPageIndex = (DataGrid1.PageCount - 1)

2) fire select.

If I understand your question correctly....

With the method that you are using, when the "edit" button is "selected",
the grid will throw the EditCommand event. Try...

Create a sub and use the Handles statement to handle the EditCommand

Private Sub DataGrid1_EditCommand(blah blah....) Handles
DataGrid1.EditCommand

....

3) Fire delete

Same as 2 except you are handling the DeleteCommand event.

4) Last row in the last page

You could place the following in an if statement...

DataGrid1.Items.Count Mod DataGrid1.PageSize = 1 And _
DataGrid1.CurrentPageIndex = DataGrid1.PageCount - 1 And_
DataGrid1.CurrentPageIndex <> 0

Good Luck!
"Ofer" <Of**@discussions.microsoft.com> wrote in message
news:78**********************************@microsof t.com...
I finally learned that
DataGrid1.EditItemIndex = {row I want} -1
DataGrid1.DataBind()

will make that row get to edit mode.
I am stiil looking for ways to programticaly do other things:
1) show the last page
2) fire select
3) fire delete
4) what is the last row in the last page

Thanks!

Nov 19 '05 #2
Thanks!
To create the event handlers is NOT the problem VS does it for me when I
select the event from the dropdaown of events.

Also when you use the buttons created by the property builder, a click on
the button does more then just fire the event. for example the the
editcommand draws text boxes for the bound columns and only then fire the
event.

what I am looking for, is the syntax to make those commands work.
for example I have a button to add a row that first inserts a new (almost
empty) row in the database then I want it to show that row and put it in edit
mode.
So all in all I want to be able to imitate the user's clicks on the command
buttons.
"James Steele" wrote:
Hi Ofer,

1) Show the last page

DataGrid1.CurrentPageIndex = (DataGrid1.PageCount - 1)

2) fire select.

If I understand your question correctly....

With the method that you are using, when the "edit" button is "selected",
the grid will throw the EditCommand event. Try...

Create a sub and use the Handles statement to handle the EditCommand

Private Sub DataGrid1_EditCommand(blah blah....) Handles
DataGrid1.EditCommand

....

3) Fire delete

Same as 2 except you are handling the DeleteCommand event.

4) Last row in the last page

You could place the following in an if statement...

DataGrid1.Items.Count Mod DataGrid1.PageSize = 1 And _
DataGrid1.CurrentPageIndex = DataGrid1.PageCount - 1 And_
DataGrid1.CurrentPageIndex <> 0

Good Luck!
"Ofer" <Of**@discussions.microsoft.com> wrote in message
news:78**********************************@microsof t.com...
I finally learned that
DataGrid1.EditItemIndex = {row I want} -1
DataGrid1.DataBind()

will make that row get to edit mode.
I am stiil looking for ways to programticaly do other things:
1) show the last page
2) fire select
3) fire delete
4) what is the last row in the last page

Thanks!


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Dinesh Upare | last post: by
6 posts views Thread by Mark | last post: by
reply views Thread by Daniel Armstrong | last post: by
7 posts views Thread by Lars Netzel | last post: by
4 posts views Thread by JJ | last post: by
1 post views Thread by Peter Rilling | last post: by
6 posts views Thread by Steve Hershoff | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.