Causing events to fire in a datagrid

Discussion in 'ASP .Net' started by =?Utf-8?B?T2Zlcg==?=, Apr 4, 2005.

  1. 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!
     
    =?Utf-8?B?T2Zlcg==?=, Apr 4, 2005
    #1
    1. Advertisements

  2. =?Utf-8?B?T2Zlcg==?=

    James Steele Guest

    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" <> wrote in message
    news:...
    >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!
     
    James Steele, Apr 5, 2005
    #2
    1. Advertisements

  3. 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" <> wrote in message
    > news:...
    > >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!

    >
    >
    >
     
    =?Utf-8?B?T2Zlcg==?=, Apr 5, 2005
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Balaji
    Replies:
    1
    Views:
    3,435
    Saravana
    Jun 26, 2003
  2. Mark
    Replies:
    6
    Views:
    702
    S. Justin Gengo
    Aug 3, 2003
  3. David Rose

    DataGrid edit events fire twice

    David Rose, Dec 14, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    787
    Microsoft
    Jan 13, 2004
  4. Simon Storr

    Datagrid events refuse to fire

    Simon Storr, Jul 15, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    246
    Simon Storr
    Jul 15, 2003
  5. Simon Storr

    Datagrid events refuse to fire (pt 2)

    Simon Storr, Jul 16, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    222
    Simon Storr
    Jul 16, 2003
  6. Jean-Pierre Fouche

    Dynamic Datagrid with TextBoxes Textchanged events wont fire

    Jean-Pierre Fouche, Jul 28, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    322
    Cristian Suazo
    Jul 29, 2003
  7. KJ
    Replies:
    1
    Views:
    263
    Teemu Keiski
    Aug 16, 2003
  8. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    654
    Chris
    Aug 30, 2005
Loading...