issue with gridview edititemtemplate

  • Thread starter news.microsoft.com
  • Start date
N

news.microsoft.com

I have been working some on a gridview to incorporate the ability to edit
data for a row. I set up TemplateFields with EditItemTemplates to
incorporate the text box controls I want for editing, but I cannot get the
text box to render. I verified that the "RowEditing" event is firing
properly when my edit image button is clicked. Could you please scan my
markup below and let me know if you see anything wrong? I have read MSDN for
an hour along with google, and I can't see anything that I am doing that
would cause the EditItemTemplate to be ignored... :( thanks!

<asp:GridView ID="GridView_TestOrders" runat="server"
AutoGenerateColumns="False" CssClass="gv_maintable"
OnRowCreated="GridView_TestOrders_RowCreated"
OnRowDeleting="GridView_TestOrders_RowDeleting"
OnRowEditing="GridView_TestOrders_RowEditing"
OnRowCancelingEdit="GridView_TestOrders_RowCancelingEdit"
OnRowUpdating="GridView_TestOrders_RowUpdating">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton_Edit" CommandName="Edit"
runat="server" ImageUrl="images/CommentHS.png" />
<asp:ImageButton ID="ImageButton_Delete"
CommandName="Delete" runat="server" ImageUrl="images/rightsrestrictedhs.png"
/>
<asp:ImageButton ID="ImageButton_Update"
CommandName="Update" runat="server" ImageUrl="images/SaveHS.png" />
<asp:ImageButton ID="ImageButton_Cancel"
CommandName="Cancel" runat="server" ImageUrl="images/Edit_UndoRed.png" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="TEST#" DataField="TestNumber" />
<asp:BoundField HeaderText="TEST NAME" DataField="TestName" />
<asp:TemplateField HeaderText="COL">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "dataval") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox_DataEdit" runat="server" Text='<%#
Eval("dataval") %>' Width="55"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
 
J

John Parrish

In case anyone is interested I figured out my problem. I wasn't aware that
within the OnRowEditing handler you had to actually set the EditIndex for
the row that was clicked.. that doesn't make sense to me since the
GridViewEditEventArgs contains the index of the row that was selected to
edit. I suppose it is there to give anyone that wants to subclass the
gridview some flexibility.

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top