Datagrid EnableViewState OnItemCommand Problems

Discussion in 'ASP .Net Datagrid Control' started by james@instantecommerce.co.uk, Jun 11, 2006.

  1. Guest

    Hi

    I disable the view state within my datagrids using the code below...

    private void Page_PreRender(object sender, EventArgs e) {
    foreach (DataGridItem dataGridItem in dgdData.Items)
    dgdData.EnableViewState = false;
    }

    I also always include the add and details buttons to the datagrid
    within a template column as below...

    <asp:TemplateColumn>
    <HeaderTemplate>
    <asp:Button ID="btnAdd" runat="Server"
    CommandName="Add" Style="width: 50px" Text="Add" />
    </HeaderTemplate>
    <ItemTemplate>
    <asp:Button ID="btnDetails" runat="Server"
    CommandName="Details" Style="width: 50px" Text="Details" />
    </ItemTemplate>
    </asp:TemplateColumn>

    The problem that I am experiencing is that for some data grid views,
    clicking on a button results in a postback and a call to the oncommand
    member function, but not to the prerender. This is as expected.

    For others, the postback is called, the oncommand member function is
    not called, but the prerender function is. This seems bizarre.

    Has anyone else come across this. Is is a Microsoft bug?

    Regards

    James
     
    , Jun 11, 2006
    #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. Rick White
    Replies:
    1
    Views:
    1,602
    Natty Gur
    Jan 13, 2004
  2. LeAnne
    Replies:
    0
    Views:
    1,104
    LeAnne
    May 14, 2006
  3. Steve Hershoff
    Replies:
    0
    Views:
    408
    Steve Hershoff
    Aug 9, 2006
  4. Sonal

    datagrid onitemcommand not firing

    Sonal, Oct 29, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    169
    Sushila [MVP]
    Oct 30, 2004
  5. Steve Hershoff

    DataGrid paging-- OnItemCommand not respecting page number?

    Steve Hershoff, Aug 9, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    200
    Steve Hershoff
    Aug 9, 2006
Loading...

Share This Page