GridView

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ata@mailinator.com

    #16
    Re: GridView

    On Jun 1, 3:26 pm, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
    <a...@mailinato r.comwrote in message
    >
    news:38694e80-884e-4a8b-83d0-a4c17c4afa25@m3 g2000hsc.google groups.com...
    >
    1. How am I supposed to have a RowIndex column *without* modifying the
    Entity class?
    >
    Firstly, you're not "supposed to" have a RowIndex column - there's no law
    that says you have to have one...
    >
    However, it's easy enough:
    >
    1) Add a template field to your existing GridView:
    >
    <asp:TemplateFi eld HeaderText="Row Index">
    <ItemTemplate >
    <asp:Label ID="lblRowIndws " runat="server" />
    </ItemTemplate>
    </asp:TemplateFie ld>
    >
    2) Wire up a RowDataBound event to your GridView if it doesn't already have
    one:http://msdn.microsoft.com/en-us/libr...ebcontrols.gri...
    >
    3) Add the following code to the RowDataBound event:
    >
    protected void gvResults_RowDa taBound(object sender, GridViewRowEven tArgs e)
    {
    if (e.Row.RowType == DataControlRowT ype.DataRow)
    {
    e.Row.Cells[0].Text = e.Row.RowIndex. ToString();
    //e.Row.Cells[6].Text = (Convert.ToInt3 2(e.Row.RowInde x) +
    1).ToString();
    }
    >
    }
    >
    Remember to modify the cell indexer accordingly...
    >
    2. How am I supposed to assign a given TAG object to each row?
    >
    Can you please explain what you mean by "given TAG object"...?
    >
    --
    Mark Rae
    ASP.NET MVPhttp://www.markrae.net
    Back to the original question and the solution you've just provided.
    I've noticed that when I press the save button, that's being placed
    somewhere
    outside the gridview control (which causes the postback and hence the
    submit behavior),
    the row# column doesn't get updated. I've traced the code and I
    noticed that the
    gridView_RowDat aBound function doesn't get called for DataRow row
    types!!!

    Would you please let me know what's going on wrong and how am I
    supposed to fix this?

    Thanks

    Comment

    • Mark Rae [MVP]

      #17
      Re: GridView

      <ata@mailinator .comwrote in message
      news:074b1fbe-107e-4a20-9b1c-5f995549c823@e3 9g2000hsf.googl egroups.com...
      The problem I'm referring to is actually posted here.
      http://www.themssforum.com/Asp/GridV...inding-409915/
      Hmm - looks like that's a bug in VS.NET 2005. It *appears* to have been
      fixed in 2008...


      --
      Mark Rae
      ASP.NET MVP


      Comment

      • Mark Rae [MVP]

        #18
        Re: GridView

        <ata@mailinator .comwrote in message
        news:216e18f0-a1b0-47ab-9249-b8112b1266c5@k3 7g2000hsf.googl egroups.com...
        Back to the original question and the solution you've just provided.
        I've noticed that when I press the save button, that's being placed
        somewhere
        outside the gridview control (which causes the postback and hence the
        submit behavior),
        the row# column doesn't get updated. I've traced the code and I
        noticed that the
        gridView_RowDat aBound function doesn't get called for DataRow row
        types!!!
        >
        Would you please let me know what's going on wrong and how am I
        supposed to fix this?
        I'm unable to reproduce this behaviour - can you please show your code...


        --
        Mark Rae
        ASP.NET MVP


        Comment

        Working...