Platform - VS2005 C# ASP
Hi all I am having a very frustrating time with this problem and cannot for the life of me work out why it isn’t working.
I have a datalist with an Itemtemplate and an EditTemplate and all I am trying to trigger the EditItemTemplate to appear when an Edit button is pressed. Simple you’d think! But for some reason it refuses to enter into the EditItemTemplate ASP code. The ItemTemplate is working fine.
I have based my code on what the previous developer wrote for another similar webpage and I have basically copied his code almost exactly. The only major differences I can think of is that the previous developer appeared to create his templates via the VS GUI.
Anyway here is my code behind. Firstly the start of the class.
Here is the code behind that handles the edit command. Note this code works fine, when the Edit button is clicked on the datalist it enters this code and triggers the page.databind ok.
Now here is my ASP – Firstly here is the header code – not sure if im missing something here?
Now here is the actual ASP datalist code – ive trimmed it right down. When the Page.Databind is triggered from DataList4_Command it just ignores theh EditItemTemplate and jumps the code for Datalist5 below.
Can anyone see me why this is not working?
Thanks in advance.
Hi all I am having a very frustrating time with this problem and cannot for the life of me work out why it isn’t working.
I have a datalist with an Itemtemplate and an EditTemplate and all I am trying to trigger the EditItemTemplate to appear when an Edit button is pressed. Simple you’d think! But for some reason it refuses to enter into the EditItemTemplate ASP code. The ItemTemplate is working fine.
I have based my code on what the previous developer wrote for another similar webpage and I have basically copied his code almost exactly. The only major differences I can think of is that the previous developer appeared to create his templates via the VS GUI.
Anyway here is my code behind. Firstly the start of the class.
Code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.ComponentModel;
//using System.Web.SessionState;
namespace Property
{
public partial class CallLogDetail : System.Web.UI.Page
//public partial class CallLogDetail : CallLogDetail
{
protected CallLog m_CallLog = new CallLog();
protected void Page_Load(object sender, EventArgs e)
{
DataList4.ItemCommand += new DataListCommandEventHandler(this.DataList4_Command);
DataList4.EditCommand += new DataListCommandEventHandler(this.DataList4_Command);
if (!IsPostBack)
{
///……other code…etc
Here is the code behind that handles the edit command. Note this code works fine, when the Edit button is clicked on the datalist it enters this code and triggers the page.databind ok.
Code:
private void DataList4_Command(object sender, DataListCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
DataList4.EditItemIndex = e.Item.ItemIndex;
Page.DataBind();
return;
}
}
///……other code…etc
Now here is my ASP – Firstly here is the header code – not sure if im missing something here?
Code:
<%@ Page Language="C#" CodeFile="CallLogDetail.aspx.cs" Inherits="Property.CallLogDetail" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Untitled Page</title>
<link href="/Property/CSS/Shoezone.css" rel="stylesheet" type="text/css" />
<SCRIPT LANGUAGE="JavaScript" SRC="/Property/CalendarPopup.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">document.write(getCalendarStyles());</SCRIPT>
</head>
<body>
<form id="form1" runat="server">
<div id="wrapper">
Now here is the actual ASP datalist code – ive trimmed it right down. When the Page.Databind is triggered from DataList4_Command it just ignores theh EditItemTemplate and jumps the code for Datalist5 below.
Code:
<asp:DataList ID="DataList4" runat="server" DataSource="<%# m_CallLog.CallOrders %>" >
<EditItemTemplate>
Some text
</EditItemTemplate>
<ItemTemplate>
Some text
<asp:Button ID="Button2" runat="server"
CommandName="Edit" Text="Button" />
</ItemTemplate>
</asp:DataList>
<div class="data" id="tableContainer" style="height: 90%; border-color:Azure;">
<table>
<asp:DataList ID="DataList5" runat="server" DataSource="<%# m_CallLog.CallComments %>" >
<ItemTemplate>
Some more text
</ItemTemplate>
</asp:DataList></table>
</div>
</form>
</body>
</html>
Can anyone see me why this is not working?
Thanks in advance.