Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 27th, 2008, 01:14 PM
Authorized User
 
Join Date: May 2006
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default datagrid editcommand firing but not editTemplate

I swear I've done this countless times before, but can't get it to work now. Have a datagrid with edit/cancel/update/delete and add in the footer. I can add, delete, but when the edit command fires, the textboxes within the editTemplateColumn aren't visible. (I know the edit command fires because I set a textbox.text to the value of the editItemIndex.) I'm not using codebehind but <script> tags on the same page. Any help greatly appreciated.

Code:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            GetList()
        End If
    End Sub
    Sub GetList()
        Dim objConn As New Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("~\App_Data\myDB.mdb"))
        objConn.Open()
        Dim ds As Data.DataSet = New Data.DataSet()
        Dim objAdapter As New Data.OleDb.OleDbDataAdapter("SELECT contactID, firstname,lastname, address, city, state, zip, phoneHome, phoneWork, email, newsletter FROM myTbl order by lastname, firstname", objConn)
        Dim objCmdBld As New Data.OleDb.OleDbCommandBuilder(objAdapter)
        objAdapter.Fill(ds, "list")
        dgList.DataSource = ds.Tables("list")
        dgList.DataBind()
        dgList.ShowFooter = True
        objConn.Close()
    End Sub
    Protected Sub dgList_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgList.ItemCommand
        lblMsg.Text = String.Empty
        If e.CommandName = "Edit" Then
            dgList.EditItemIndex = e.Item.ItemIndex
            myID.Text = e.Item.ItemIndex.ToString

Code:
    <asp:dataGrid ID="dgList" runat="server" SkinID="dg" AutoGenerateColumns="false">
        <Columns>
            <asp:BoundColumn visible="false" dataField="contactID"  />
            <asp:EditCommandColumn EditText="Edit" UpdateText="Upd" CancelText="Cxl" ButtonType="PushButton"  />
            <asp:TemplateColumn>
                <FooterTemplate><asp:Button CommandName="Insert" Text="Add" Runat="server" ID="btnAdd" /></FooterTemplate>
                <ItemTemplate><asp:Button CommandName="Delete" Text="Del" Runat="server" ID="btnDel" /></ItemTemplate>
            </asp:TemplateColumn>
            <asp:TemplateColumn HeaderText="Wants Newsletter?" >
                <FooterTemplate><asp:CheckBox ID="chkNews" runat="server" /></FooterTemplate>
                <ItemTemplate><asp:CheckBox ID="chkNewsD" runat="server" Enabled="false" Checked="false" /></ItemTemplate>
                <EditItemTemplate><asp:CheckBox ID="chkNewsE" runat="server" /></EditItemTemplate>
            </asp:TemplateColumn>
            <asp:BoundColumn DataField="newsletter" Visible="true" />


Similar Threads
Thread Thread Starter Forum Replies Last Post
Events are not firing msrnivas .NET Web Services 14 April 21st, 2008 06:37 AM
Datagrid ItemCommand firing twice spacky001 ASP.NET 1.0 and 1.1 Basics 1 May 16th, 2007 11:06 AM
Firing Blanks... ozPATT Access VBA 11 January 20th, 2006 11:26 AM
Datagrid Editcommand for 1 rcrd on 2nd page bubberz ASP.NET 1.0 and 1.1 Professional 0 January 19th, 2006 05:50 PM
Class_Terminate not firing ddebreceni Beginning VB 6 4 July 14th, 2003 11:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.