[Framework 2.0] Any examples of using a GridView in "manual" mode?

Discussion in 'ASP .Net' started by Jeff Johnson, Sep 29, 2009.

  1. Jeff Johnson

    Jeff Johnson Guest

    I'm using a GridView which I am binding directly to a data source, i.e., I
    am NOT using a data source control. Why not? Don't wanna. Anyways, I don't
    know how to put the grid into edit mode. I have an edit-type command button,
    but I don't know what to do in the RowEditing event to turn on the text
    boxes in the columns that are editable.

    As you might have guessed, Web development is not my specialty, so treat me
    like a total n00B in this case. Here's my markup for the grid:

    <asp:GridView runat="server" AutoGenerateColumns="False"
    ID="interceptGridView" OnRowDeleting="interceptGridView_RowDeleting"
    OnRowEditing="interceptGridView_RowEditing">
    <Columns>
    <asp:BoundField DataField="InterceptID" HeaderText="ID" ReadOnly="True" />
    <asp:BoundField DataField="SourceNameURL" HeaderText="URL Text" />
    <asp:TemplateField HeaderText="Body Text">
    <ItemTemplate>
    <%# Convert.ToString(DataBinder.Eval(Container.DataItem, "BodyText"))%>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox runat="server" TextMode="MultiLine" ID="bodyText" />
    </EditItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Call To Action">
    <ItemTemplate>
    <%# Convert.ToString(DataBinder.Eval(Container.DataItem, "CallToAction"))%>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox ID="callToAction"
    runat="server" TextMode="MultiLine">
    </asp:TextBox>
    </EditItemTemplate>
    </asp:TemplateField>
    <asp:CommandField ShowEditButton="True" />
    <asp:CommandField ShowDeleteButton="True" />
    </Columns>
    </asp:GridView>


    I tried doing

    interceptGridView.EditIndex = e.NewEditIndex;

    in the RowEditing event, but no text boxes showed up. I also read a post
    where constant data binding was a problem, so I made sure I'm not binding
    the grid during a postback. Still no luck.

    What kind of dumb error am I making?
    Jeff Johnson, Sep 29, 2009
    #1
    1. Advertising

  2. Jeff Johnson

    Jeff Johnson Guest

    "Jeff Johnson" <> wrote in message
    news:eh$...

    > What kind of dumb error am I making?


    My dumb error was in not re-binding the grid after setting EditIndex.
    (Current) problem solved.
    Jeff Johnson, Sep 29, 2009
    #2
    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. imavroid
    Replies:
    0
    Views:
    827
    imavroid
    Mar 12, 2006
  2. John J Lee
    Replies:
    3
    Views:
    456
    bruno at modulix
    Dec 1, 2005
  3. Frank
    Replies:
    2
    Views:
    421
    Sarath
    Mar 22, 2007
  4. Edward Loper
    Replies:
    0
    Views:
    444
    Edward Loper
    Aug 7, 2007
  5. John J Lee
    Replies:
    0
    Views:
    502
    John J Lee
    Aug 7, 2007
Loading...

Share This Page