EditItemTemplate column not displaying on first EditCommand click

Discussion in 'ASP .Net Datagrid Control' started by DM, Jan 10, 2004.

  1. DM

    DM Guest

    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>
     
    DM, Jan 10, 2004
    #1
    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. =?Utf-8?B?V2ViTWF0cml4?=

    DataList EditCommand displaying Different EditItemTemplates

    =?Utf-8?B?V2ViTWF0cml4?=, Mar 14, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    1,212
    =?Utf-8?B?V2ViTWF0cml4?=
    Mar 14, 2006
  2. Jim in Arizona

    EditItemTemplate not showing on first click

    Jim in Arizona, Oct 11, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    447
    Jim in Arizona
    Oct 11, 2006
  3. sjmyers
    Replies:
    0
    Views:
    1,788
    sjmyers
    Mar 27, 2007
  4. Nedu N

    controlling size of editcommand column in edit mode

    Nedu N, Aug 15, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    134
    vMike
    Aug 24, 2003
  5. Teej
    Replies:
    2
    Views:
    337
Loading...

Share This Page