ASP Data Grid Edit

black_cyber89

New Member
I got a data grid and it displays all the information but when I go to click on edit it just shows up with a blank screen. I followed the quickstart example pretty much to a T. contact search is the name of the subroutine that puts the data into the aspdata grid which works so I won't post that. I don't know what I am missing. Anyway here is my code:<BR><BR>VB Code: <BR><BR>Sub MyDataGrid_Edit(Sender As Object, E As DataGridCommandEventArgs)<BR> MyDataGrid.EditItemIndex = E.Item.ItemIndex<BR> contactsearch()<BR>End Sub<BR><BR>Sub MyDataGrid_Cancel(Sender As Object, E As DataGridCommandEventArgs)<BR><BR> MyDataGrid.EditItemIndex = -1<BR> contactsearch()<BR>End Sub<BR><BR>Sub MyDataGrid_Update(Sender As Object, E As DataGridCommandEventArgs)<BR><BR>response.write ("Update")<BR><BR>End Sub<BR><BR>DataGrid:<BR><BR><asp:DataGrid id="MyDataGrid" runat="server"<BR> Width="100%"<BR> BackColor="skyblue" <BR> BorderColor="blue"<BR> ShowFooter="false" <BR> CellPadding=3 <BR> CellSpacing="0"<BR> Font-Name="Verdana"<BR> Font-Size="8pt"<BR> GridLines="Horizontal"<BR> HeaderStyle-BackColor="lightblue"<BR> HeaderStyle-HorizontalAlign="center"<BR> ItemStyle-HorizontalAlign="center"<BR> AlternatingItemStyle-BackColor="white"<BR> OnEditCommand="MyDataGrid_Edit"<BR> OnCancelCommand="MyDataGrid_Cancel"<BR> OnUpdateCommand="MyDataGrid_Update"<BR> EnableViewState="False"<BR> DataKeyField="id"<BR> AutoGenerateColumns="false" ><BR><BR> <Columns><BR> <asp:BoundColumn HeaderText="id" ReadOnly="True" DataField="id" ItemStyle-Wrap="false"/><BR> <asp:EditCommandColumn canceltext="Cancel" EditText="Edit" UpdateText="Update" /><BR> <asp:TemplateColumn HeaderText="Name"><BR> <ItemTemplate><BR> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "empname") %>'/><BR> </ItemTemplate><BR> <EditItemTemplate><BR> <asp:TextBox runat="server" id="empname" Text='<%# DataBinder.Eval(Container.DataItem, "empname") %>'/><BR> </EditItemTemplate><BR> </asp:TemplateColumn><BR> <asp:TemplateColumn HeaderText="Ext."><BR> <ItemTemplate><BR> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "exten") %>'/><BR> </ItemTemplate><BR> <EditItemTemplate><BR> <asp:TextBox runat="server" id="exten" Text='<%# DataBinder.Eval(Container.DataItem, "exten") %>'/><BR> </EditItemTemplate><BR> </asp:TemplateColumn><BR> <asp:TemplateColumn HeaderText="Misc"><BR> <ItemTemplate><BR> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "misc") %>'/><BR> </ItemTemplate><BR> <EditItemTemplate><BR> <asp:TextBox runat="server" id="misc" Text='<%# DataBinder.Eval(Container.DataItem, "misc") %>'/><BR> </EditItemTemplate><BR> </asp:TemplateColumn><BR> <BR> <asp:TemplateColumn HeaderText="Email"><BR> <ItemTemplate><BR> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "email") %>'/><BR> </ItemTemplate><BR> <EditItemTemplate><BR> <asp:TextBox runat="server" id="email" Text='<%# DataBinder.Eval(Container.DataItem, "email") %>'/><BR> </EditItemTemplate><BR> </asp:TemplateColumn><BR> <BR> </Columns><BR> <BR></asp:DataGrid><BR><BR>MattI figured out why its not working. OnEditCommand does not execute. It runs like I don't have an OnEditCommand even though I have one. but why would it not execute?<BR><BR>MattBe sure the view state is set to true or you end up with nothing!<BR><BR>Matt
 
Back
Top