ItemCommand, ButtonColumn and Paging

Discussion in 'ASP .Net Datagrid Control' started by lac61675@yahoo.com, Jun 7, 2005.

  1. Guest

    Hi all,

    I hope you can help me out on this one. I am creating a dynamic
    datagrid within a user control. I have a function that builds columns
    and formats the datagrid in Page_Init. I add the datagrid to a table
    control dynamically in Page_Load.

    When I build the columns, I set the first column in the control to be a
    buttoncolumn as follows:

    btc = New ButtonColumn()
    btc.ButtonType = ButtonColumnType.PushButton
    btc.Text = "Details"
    btc.CommandName = "Details"
    dg1.Columns.Add(btc)

    After all columns are designed, I call a function that sets paging
    Mode=NextPrev:
    dg1.PagerStyle.Mode = PagerMode.NextPrev
    dg1.PagerStyle.NextPageText = "Next >"
    dg1.PagerStyle.PrevPageText = "< Previous"

    The problem occurs when ItemCommand is fired during paging. It works
    fine for "Next", but "Previous" is causing a problem -- the
    e.CommandName returns "Details", which is the command name for the
    button column.

    Public Sub dg1_ItemCommand(ByVal sender As Object, ByVal e As
    DataGridCommandEventArgs) Handles dg1.ItemCommand

    If e.CommandName <> "Page" Then
    Dim tcButtonCol As TableCell = e.Item.Cells(0)
    Dim tcDayCode As TableCell = e.Item.Cells(1)
    DayCode = Trim(tcDayCode.Text)

    RaiseEvent DGButtonClick(sender, e)
    End If

    End Sub

    Does anyone why this is happening and how to resolve it? I have tried
    e.Item.ItemIndex = -1, but "Previous" returns index 9 (and my grid
    PageSize is 10). I've also tried e.CommandArgument, which returns
    "Next" for Next, but empty string for Previous.

    Thanks for your help,
    Laura
     
    , Jun 7, 2005
    #1
    1. Advertising

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. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    DataSet paging vs Datareader paging

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Oct 8, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    10,865
    Scott Allen
    Oct 8, 2004
  2. wh1974
    Replies:
    0
    Views:
    2,491
    wh1974
    Jan 12, 2005
  3. Red
    Replies:
    1
    Views:
    767
  4. Piotr
    Replies:
    0
    Views:
    428
    Piotr
    Jan 6, 2006
  5. Piotr
    Replies:
    2
    Views:
    157
    Piotr
    Jan 9, 2006
Loading...

Share This Page