EditItemTemplate column not displaying on first EditCommand click

D

DM

For some reason, when I click the edit template command button on my grid,
the edit command fires, but the edit template controls don't display. When
I click the Edit command again, the Update command fires but then the edit
template controls display. It appears that the rendering is a step behind
what is actually happening. What could I be doing wrong?

'Click 1 - this event fires but edit controls don't render
Sub dgCat1_Edit(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgCat1.EditCommand
dgCat1.EditItemIndex = e.Item.ItemIndex
End Sub

Sub dgCat1_Cancel(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgCat1.CancelCommand
dgCat1.EditItemIndex = -1
End Sub

'Click 2 - this event fires, and the edit controls render
Sub dgCat1_Save(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgCat1.UpdateCommand
'Save record
Dim newTB As TextBox
dnewTBw =
dgCat1.Items(e.Item.ItemIndex).Cells(2).FindControl("txtPriorityEdit")
Dim strNewVal As String = newTB.Text
'Call storedproc to act on user input

---------------------------

<asp:datagrid id="dgCat1" style="Z-INDEX: 105; LEFT: 14px;
POSITION: absolute; TOP: 3px" runat="server" Font-Names="Arial"
Width="339px" Font-Size="XX-Small" Height="5px" AutoGenerateColumns="False"
OnEditCommand="dgCat1_Edit" OnCancelCommand="dgcat1_Cancel"
OnUpdateCommand="dgCat1_Save" DataKeyField="ID">
<AlternatingItemStyle BackColor="#CCCCFF"></AlternatingItemStyle>
<HeaderStyle Font-Size="X-Small" Font-Names="Arial" Font-Bold="True"
ForeColor="White" BackColor="Black"></HeaderStyle>
<Columns>
<asp:BoundColumn Visible="False" DataField="ID" ReadOnly="True"
HeaderText="ID"></asp:BoundColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button runat="server" Text="Edit" CommandName="Edit"
CausesValidation="false"></asp:Button>
</ItemTemplate>
<EditItemTemplate>
<asp:Button runat="server" Text="Save"
CommandName="Update"></asp:Button>&nbsp;
<asp:Button runat="server" Text="Cancel" CommandName="Cancel"
CausesValidation="false"></asp:Button>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Priority">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container,
"DataItem.Priority") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" Text='<%# DataBinder.Eval(Container,
"DataItem.Priority") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="CATEG_NBR_SUB" ReadOnly="True"
HeaderText="NBR">
<HeaderStyle Width="50px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="CATEG_DESC" ReadOnly="True"
HeaderText="Category">
<HeaderStyle Width="150px"></HeaderStyle>
</asp:BoundColumn>
</Columns>
</asp:datagrid>
 

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

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top