[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. Advertisements

  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. 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. imavroid
    Replies:
    0
    Views:
    952
    imavroid
    Mar 12, 2006
  2. Kikoz
    Replies:
    6
    Views:
    532
    Indentix, Inc.
    Jul 27, 2004
  3. John J Lee
    Replies:
    3
    Views:
    801
    bruno at modulix
    Dec 1, 2005
  4. Frank
    Replies:
    2
    Views:
    501
    Sarath
    Mar 22, 2007
  5. Steve Cross

    Manual .Net 2.0 Framework Uninstall

    Steve Cross, Jul 17, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    693
    Juan T. Llibre
    Jul 17, 2007
  6. Edward Loper

    mmm-mode, python-mode and doctest-mode?

    Edward Loper, Aug 9, 2007, in forum: Python
    Replies:
    0
    Views:
    646
    Edward Loper
    Aug 9, 2007
  7. CJM
    Replies:
    2
    Views:
    371
  8. CJM
    Replies:
    0
    Views:
    428
Loading...