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

  • Thread starter Thread starter Jeff Johnson
  • Start date Start date
J

Jeff Johnson

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?
 
Back
Top