Jeg poster lige det hele: Jeg rammer ikke noget i min debugger
Min cs-fil.
namespace webkalender
{
/// <summary>
/// Summary description for closed.
/// </summary>
public class closed : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid Gridclosed;
OleDbConnection myConn;
protected System.Web.UI.WebControls.Label Label1;
OleDbDataAdapter myCmd;
private void Page_Load(object sender, System.EventArgs e)
{
string strDSN=@"Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=";
strDSN+=Server.MapPath("data\\kalender.mdb");
myConn = new OleDbConnection(strDSN);
string close = "Select id,dato, tid, brugerid From event Where emne='Dagen er lukket'";
myCmd = new OleDbDataAdapter(close, myConn);
myConn.Open();
DataSet ds = new DataSet();
myCmd.Fill(ds,"event");
if(ds.Tables[0].Rows.Count==0)
{
Gridclosed.Visible=false;
Label1.Visible=true;
}
else
{
Label1.Visible=false;
Gridclosed.DataSource= ds;
Gridclosed.DataBind();
Gridclosed.Visible=true;
}
if (!IsPostBack)
{
this.Gridclosed.DataSource = ds;
this.Gridclosed.DataBind();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Gridclosed.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.Gridclosed_DeleteCommand);
this.Gridclosed.SelectedIndexChanged += new System.EventHandler(this.Gridclosed_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Gridclosed_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string s = e.Item.Cells[0].Text;
OleDbCommand myCommand = new OleDbCommand("DELETE FROM event WHERE id="+s,myConn);
myCommand.CommandType = CommandType.Text;
myConn.Open();
myCommand.ExecuteNonQuery();
myConn.Close();
Gridclosed.DataBind();
}
}
}
Min aspx
<%@ Page language="c#" Codebehind="closed.aspx.cs" AutoEventWireup="false" Inherits="webkalender.closed" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>closed</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="
http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
</SCRIPT>
<form id="closed" method="post" runat="server">
<asp:datagrid id="Gridclosed" style="Z-INDEX: 101; LEFT: 28px; POSITION: absolute; TOP: 13px" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="3" BackColor="White" BorderWidth="1px" BorderStyle="None" BorderColor="#CCCCCC">
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#669999"></SelectedItemStyle>
<ItemStyle ForeColor="#000066"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#006699"></HeaderStyle>
<FooterStyle ForeColor="#000066" BackColor="White"></FooterStyle>
<Columns>
<asp:BoundColumn DataField="id" HeaderText="Id"></asp:BoundColumn>
<asp:BoundColumn DataField="dato" HeaderText="Dato" DataFormatString="{0:dd/MM/yyyy}"></asp:BoundColumn>
<asp:BoundColumn DataField="brugerid" HeaderText="Navn"></asp:BoundColumn>
<asp:BoundColumn DataField="tid" HeaderText="Fra tidspunkt"></asp:BoundColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button id="Button1" runat="server" CausesValidation="false" CommandName="Delete" Text="Åben dag"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle HorizontalAlign="Left" ForeColor="#000066" BackColor="White" Mode="NumericPages"></PagerStyle>
</asp:datagrid><asp:label id="Label1" style="Z-INDEX: 102; LEFT: 50px; POSITION: absolute; TOP: 328px" runat="server" Visible="False" ForeColor="#C04000" Font-Size="Smaller" Font-Names="Verdana">Der er ingen lukkede dage</asp:label>
</form>
</body>
</HTML>
Men det må da være lavet et eller andet så det er nemt at slette... Det er jo nemt nok at indsætte data.
mvh