mathieu_cupryk
asked on
Invalid cast question.
Server Error in '/MSPOS' Application.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastExceptio n: Specified cast is not valid.
Source Error:
Line 170: {
Line 171: string strValue="Javascript:OpenN ewWin('" + DecodeReceipt(e.Item.Cells [3].Text) + "');";
Line 172: HtmlButton btn=(HtmlButton)(e.Item.Ce lls[5].Con trols[0]);
Line 173: btn.Attributes.Add("Onclic k",strValu e);
Line 174: }
Source File: c:\inetpub\wwwroot\mspos\r eceipts.as px.cs Line: 172
Here is .aspx:
<%@ Register TagPrefix="cc1" Namespace="ActiveUp.WebCon trols" Assembly="ActiveDateTime" %>
<%@ Page Language="c#" trace="true" Codebehind="Receipts.aspx. cs" AutoEventWireup="false" Inherits="MSPOS.Receipts" CompilerOptions='/R:"C:\Pr ogram Files\Microsoft.NET\Odbc.N et\Microso ft.data.od bc.dll"'%>
<%@ Register TagPrefix="uc1" TagName="logout" Src="Engine/Controls/logou t.ascx" %>
<%@ Register TagPrefix="mspos" TagName="header" Src="Engine/Controls/heade r.ascx" %>
<%@ Register TagPrefix="mspos" TagName="footer" Src="~/Engine/Controls/foo ter.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<script language="javascript">
function OpenNewWin(Receipt)
{
winNew= window.open("print.html?", "printwind ow","toolb ar=no,scro llbar=no,h eight=200, width=300, resizable= no,top=200 ,left=200" );
var PrintHtml ="<Table cellpadding=5 cellspacing=5 broder=0>";
PrintHtml = PrintHtml + "<TR><TD>Receipt</TD><TD width=5>:</TD><TD>" + Receipt + "</TD></TR>";
PrintHtml = PrintHtml + " </TABLE>";
PrintHtml = PrintHtml + " <DIV id=butPanel align=center> <input Type=button value=' Print ' onclick=Javascript:documen t.getEleme ntById('bu tPanel').s tyle.displ ay='none'; window.pri nt();docum ent.getEle mentById(' butPanel') .style.dis play='';>" ;
PrintHtml = PrintHtml + " <input type=button value=cancel onclick=javascript:window. close();>< /Div>";
winNew.document.body.inner HTML=Print Html;
winNew.focus();
}
</script>
</HEAD>
<BODY leftMargin="0" background="images/bg.gif" topMargin="0">
<form id="Form1" action="database.aspx" method="post" runat="server">
<strong>
<P><mspos:header id="Header1" runat="server"></mspos:hea der><BR>
<FONT face="Verdana" size="2"></FONT>
</P>
<P><FONT face="Verdana" size="2"></FONT> </P>
<FONT face="Verdana" size="2">
<P>
<TABLE id="Table2" height="118" cellSpacing="1" cellPadding="1" width="355" border="0">
<TR>
<TD vAlign="top" width="147" colSpan="1" rowSpan="4">
<P><asp:radiobuttonlist id="Group_RadioButtonList" runat="server" BorderWidth="0px" CellSpacing="1" CellPadding="1"
Height="111px" Font-Bold="True" Font-Size="12px" Font-Names="Verdana" Width="35px" BackColor="#FEF9E9">
<asp:ListItem Value="PayNumber">1</asp:L istItem>
<asp:ListItem Value="Cashier">2</asp:Lis tItem>
<asp:ListItem Value="StartDate">3</asp:L istItem>
</asp:radiobuttonlist></P>
</TD>
<TD noWrap colSpan="1" rowSpan="1">Payment Number:</TD>
<TD vAlign="middle" noWrap width="200" colSpan="1" rowSpan="1"><asp:textbox id="txtPayment" runat="server" MaxLength="10"></asp:textb ox></TD>
</TR>
<TR>
<TD width="240">Cashier Number:</TD>
<TD><asp:textbox id="txtCashier" runat="server" MaxLength="8"></asp:textbo x></TD>
</TR>
<TR>
<TD width="240" height="10">Start Date:</TD>
<TD height="10"><cc1:activedat etime id="ActiveDateTime3" runat="server" AllowNull="False" MonthNamesDisabled="True"
Format="DAY;-;MONTH;-;YEAR "></cc1:ac tivedateti me></TD>
</TR>
<TR>
<TD width="240">End Date: &nb sp;
</TD>
<TD><cc1:activedatetime id="ActiveDateTime4" runat="server" AllowNull="False" MonthNamesDisabled="True"
Format="DAY;-;MONTH;-;YEAR "></cc1:ac tivedateti me></TD>
</TR>
<TR>
<TD width="240"></TD>
<TD><asp:button id="btnRunQuery" onclick="btnRunQuery_Click " runat="server" text="Run Query" type="submit"></asp:button ></TD>
</TR>
</TABLE>
</FONT></strong>
<br>
<strong>Results of:</strong>
<asp:datagrid id="ReceiptsDataGrid" runat="server" BorderWidth="3" CellSpacing="1" CellPadding="1"
Height="144px" Width="500px" OnItemDataBound="ReceiptsD ataGrid_It emDataBoun d" OnItemCommand="ReceiptsDat aGrid_Item Command"
HeaderStyle-Font-Bold="Tru e" maintainviewstate="false" GridLines="None" BorderStyle="Outset"
font-size="XX-Small" font-names="Verdana" BorderColor="#CCCC99" AutoGenerateColumns="False ">
<AlternatingItemStyle Wrap="False" BackColor="PaleGoldenrod"> </Alternat ingItemSty le>
<ItemStyle Wrap="False" BackColor="Beige"></ItemSt yle>
<HeaderStyle Font-Size="14px" Font-Bold="True" ForeColor="White" BackColor="#954896"></Head erStyle>
<Columns>
<asp:BoundColumn DataField="RC_PAYMNB" HeaderText="Payment Number "></asp:BoundColumn>
<asp:BoundColumn DataField="RC_CASHNB" HeaderText="Cash Number"></asp:BoundColumn>
<asp:BoundColumn DataField="RC_DATE" HeaderText="Date"></asp:Bo undColumn>
<asp:BoundColumn DataField="RC_DATA" Visible="False" HeaderText="Data"></asp:Bo undColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button CommandName="View" Text="View" Runat="server" ID="Button1"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button CommandName="Print" Text="Print" Runat="server" ID="Button2"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid></P></form>
</BODY>
</HTML>
.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Drawing;
using System.Data.Common;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls ;
using Microsoft.Data.Odbc;
namespace MSPOS
{
/// <summary>
/// Summary description for Receipts.
/// </summary>
public class Receipts : System.Web.UI.Page
{
protected System.Web.UI.WebControls. RadioButto nList Group_RadioButtonList;
protected System.Web.UI.WebControls. DataGrid ReceiptsDataGrid;
private DataSet ddlDataSet = new DataSet();
private OdbcConnection myConnection = new OdbcConnection("DSN=POS;UI D=system;P WD=system" );
protected System.Web.UI.WebControls. Button btnRunQuery;
protected System.Web.UI.WebControls. Button Button2;
protected System.Web.UI.WebControls. TextBox txtPayment;
protected System.Web.UI.WebControls. TextBox txtCashier;
private DataSet ddlDataSet1 = new DataSet();
private DataSet ddlDataSet2 = new DataSet();
protected ActiveUp.WebControls.Activ eDateTime ActiveDateTime3;
protected ActiveUp.WebControls.Activ eDateTime ActiveDateTime4;
private DataSet ddlDataSet3 = new DataSet();
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!Page.IsPostBack)
{
ActiveDateTime3.Date = System.DateTime.Today.Date ;
ActiveDateTime4.Date = System.DateTime.Today.Date ;
}
}
#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.Group_RadioButtonList .SelectedI ndexChange d += new System.EventHandler(this.G roup_Radio ButtonList _SelectedI ndexChange d);
this.txtCashier.TextChange d += new System.EventHandler(this.t xtCashier_ TextChange d);
this.btnRunQuery.Click += new System.EventHandler(this.b tnRunQuery _Click);
this.ReceiptsDataGrid.Sele ctedIndexC hanged += new System.EventHandler(this.R eceiptsDat aGrid_Sele ctedIndexC hanged);
this.Load += new System.EventHandler(this.P age_Load);
}
#endregion
public string DecodeReceipt (string szBill)
{
string szNewBill="";
// Create an ASCII encoding.
Encoding ascii = Encoding.ASCII;
Byte[] encodedBytes = ascii.GetBytes(szBill);
foreach (Byte a in encodedBytes)
{
if ( a ==10 || a ==15 ||a==18 ||a ==27)
{}
else if (a == 13)
szNewBill = szNewBill + "\\n";
else
szNewBill = szNewBill +(char) a;
}
return szNewBill;
}
private void txtPayment_TextChanged(obj ect sender, System.EventArgs e)
{
}
private void txtCashier_TextChanged(obj ect sender, System.EventArgs e)
{
}
//************************ ********** ********** ********** ********** *******
// Get RC_PAYMND and populate dataset
public DataSet BindRC_PAYMND(string searchstring)
{
OdbcConnection myConnection = new OdbcConnection("DSN=POS;UI D=system;P WD=system" );
// Populate the ddlDataSet1
myConnection.Open();
string strSQLDDL = @"SELECT RC_PAYMNB FROM TBRECEIPTS WHERE RC_PAYMNB='"+searchstring+ "'";
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL, myConnection);
ddlDataSet1.Clear();
myDataAdapter.Fill(ddlData Set1, "ddlRC_PAYMNB");
myDataAdapter.Dispose();
myDataAdapter = null;
myConnection.Close();
strSQLDDL = null;
return ddlDataSet1;
}
//************************ ********** ********** ********** ********** *******
//************************ ********** ********** ********** ********** *******
// Get RC_CASHND and populate dataset
public DataSet BindRC_CASHND(string searchstring)
{
OdbcConnection myConnection = new OdbcConnection("DSN=POS;UI D=system;P WD=system" );
// Populate the ddlDataSet2
myConnection.Open();
string strSQLDDL = @"SELECT RC_CASHNB FROM TBRECEIPTS WHERE RC_CASHNB='"+searchstring+ "'";
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL, myConnection);
ddlDataSet2.Clear();
myDataAdapter.Fill(ddlData Set2, "ddlRC_CASHNB");
myDataAdapter.Dispose();
myDataAdapter = null;
myConnection.Close();
strSQLDDL = null;
return ddlDataSet2;
}
//************************ ********** ********** ********** ********** *******
//************************ ********** ********** ********** ********** *******
// Get RC_CASHND and populate dataset with RC_CASHND and RC_DATE
public DataSet BindRC_DATE()
{
OdbcConnection myConnection = new OdbcConnection("DSN=POS;UI D=system;P WD=system" );
// Populate the ddlDataSet3
myConnection.Open();
string strSQLDDL = @"SELECT RC_DATE FROM TBRECEIPTS";
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL, myConnection);
ddlDataSet3.Clear();
myDataAdapter.Fill(ddlData Set3, "ddlRC_DATE");
myDataAdapter.Dispose();
myDataAdapter = null;
myConnection.Close();
strSQLDDL = null;
return ddlDataSet3;
}
//************************ ********** ********** ********** ********** *******
public void ReceiptsDataGrid_ItemDataB ound(objec t sender,System.Web.UI.WebCo ntrols.Dat aGridItemE ventArgs e)
{
if(e.Item.ItemType == ListItemType.AlternatingIt em || e.Item.ItemType==ListItemT ype.Item )
{
string strValue="Javascript:OpenN ewWin('" + DecodeReceipt(e.Item.Cells [3].Text) + "');";
HtmlButton btn=(HtmlButton)(e.Item.Ce lls[5].Con trols[0]);
btn.Attributes.Add("Onclic k",strValu e);
}
}
//************************ ********** ********** ********** ********** *******
public void ReceiptsDataGrid_ItemComma nd(object source, System.Web.UI.WebControls. DataGridCo mmandEvent Args e)
{
ListItemType oType = ((ListItemType)e.Item.Item Type);
if(oType == ListItemType.Item || oType == ListItemType.AlternatingIt em)
{
e.Item.Attributes.Add("onm ouseover", "this.style.backgroundColo r='lightbl ue'");
e.Item.Attributes.Add("onm ouseout", "this.style.backgroundColo r='Beige'" );
}
if(e.CommandName =="View")
{
string parsedreceipt = null;
parsedreceipt = DecodeReceipt (e.Item.Cells[3].Text);
StringBuilder strAlert = new StringBuilder();
strAlert.Append("<script language=javascript> alert('");
strAlert.Append("Receipt: " + parsedreceipt + "\\n");
strAlert.Append("');</scri pt>");
this.RegisterStartupScript ("startup" ,strAlert. ToString() );
}
}
private void Group_RadioButtonList_Sele ctedIndexC hanged(obj ect sender, System.EventArgs e)
{
}
public void btnRunQuery_Click(object sender, System.EventArgs e)
{
string select_statement = "SELECT RC_PAYMNB, RC_CASHNB, RC_DATE, RC_DATA FROM TBRECEIPTS";
string DateString1 = ActiveDateTime3.Date.Day.T oString() + ActiveDateTime3.Date.Month .ToString( ) + ActiveDateTime3.Date.Year. ToString() ;
string DateString2 = ActiveDateTime4.Date.Day.T oString() + ActiveDateTime4.Date.Month .ToString( ) + ActiveDateTime4.Date.Year. ToString() ;
Response.Write (DateString1 +"<BR>");
Response.Write (DateString2 +"<BR>");
switch (Group_RadioButtonList.Sel ectedIndex )
{
case 0:
select_statement += " Where RC_PAYMNB='" + txtPayment.Text + "'";
break;
case 1:
select_statement += " Where RC_CASHNB='" + txtCashier.Text + "'";
break;
case 2:
// select_statement += " Where To_Date(RC_DATE, 'DDMMYYYY') <=To_Date('" + DateString2.ToString("DDMM YYYY") + "', 'DDMMYYYY') And To_Date(RC_DATE, 'DDMMYYYY') >= To_Date('" + DateString1.ToString("DDMM YYYY") + "', 'DDMMYYYY')";
Response.Write (select_statement);
break;
}
OdbcConnection myConnection = new
OdbcConnection("DSN=POS;UI D=system;P WD=system" );
// Populate the ddlDataSet1
myConnection.Open();
string strSQLDDL = select_statement;
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL, myConnecti on);
ddlDataSet1.Clear();
myDataAdapter.Fill(ddlData Set1);
myDataAdapter.Dispose();
myDataAdapter = null;
myConnection.Close();
ReceiptsDataGrid.DataSourc e = ddlDataSet1.Tables[0];
ReceiptsDataGrid.DataBind( );
}
private void ReceiptsDataGrid_SelectedI ndexChange d(object sender, System.EventArgs e)
{
}
}
}
--------------------------
Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastExceptio
Source Error:
Line 170: {
Line 171: string strValue="Javascript:OpenN
Line 172: HtmlButton btn=(HtmlButton)(e.Item.Ce
Line 173: btn.Attributes.Add("Onclic
Line 174: }
Source File: c:\inetpub\wwwroot\mspos\r
Here is .aspx:
<%@ Register TagPrefix="cc1" Namespace="ActiveUp.WebCon
<%@ Page Language="c#" trace="true" Codebehind="Receipts.aspx.
<%@ Register TagPrefix="uc1" TagName="logout" Src="Engine/Controls/logou
<%@ Register TagPrefix="mspos" TagName="header" Src="Engine/Controls/heade
<%@ Register TagPrefix="mspos" TagName="footer" Src="~/Engine/Controls/foo
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<script language="javascript">
function OpenNewWin(Receipt)
{
winNew= window.open("print.html?",
var PrintHtml ="<Table cellpadding=5 cellspacing=5 broder=0>";
PrintHtml = PrintHtml + "<TR><TD>Receipt</TD><TD width=5>:</TD><TD>" + Receipt + "</TD></TR>";
PrintHtml = PrintHtml + " </TABLE>";
PrintHtml = PrintHtml + " <DIV id=butPanel align=center> <input Type=button value=' Print ' onclick=Javascript:documen
PrintHtml = PrintHtml + " <input type=button value=cancel onclick=javascript:window.
winNew.document.body.inner
winNew.focus();
}
</script>
</HEAD>
<BODY leftMargin="0" background="images/bg.gif"
<form id="Form1" action="database.aspx" method="post" runat="server">
<strong>
<P><mspos:header id="Header1" runat="server"></mspos:hea
<FONT face="Verdana" size="2"></FONT>
</P>
<P><FONT face="Verdana" size="2"></FONT> </P>
<FONT face="Verdana" size="2">
<P>
<TABLE id="Table2" height="118" cellSpacing="1" cellPadding="1" width="355" border="0">
<TR>
<TD vAlign="top" width="147" colSpan="1" rowSpan="4">
<P><asp:radiobuttonlist id="Group_RadioButtonList"
Height="111px" Font-Bold="True" Font-Size="12px" Font-Names="Verdana" Width="35px" BackColor="#FEF9E9">
<asp:ListItem Value="PayNumber">1</asp:L
<asp:ListItem Value="Cashier">2</asp:Lis
<asp:ListItem Value="StartDate">3</asp:L
</asp:radiobuttonlist></P>
</TD>
<TD noWrap colSpan="1" rowSpan="1">Payment Number:</TD>
<TD vAlign="middle" noWrap width="200" colSpan="1" rowSpan="1"><asp:textbox id="txtPayment" runat="server" MaxLength="10"></asp:textb
</TR>
<TR>
<TD width="240">Cashier Number:</TD>
<TD><asp:textbox id="txtCashier" runat="server" MaxLength="8"></asp:textbo
</TR>
<TR>
<TD width="240" height="10">Start Date:</TD>
<TD height="10"><cc1:activedat
Format="DAY;-;MONTH;-;YEAR
</TR>
<TR>
<TD width="240">End Date: &nb
</TD>
<TD><cc1:activedatetime id="ActiveDateTime4" runat="server" AllowNull="False" MonthNamesDisabled="True"
Format="DAY;-;MONTH;-;YEAR
</TR>
<TR>
<TD width="240"></TD>
<TD><asp:button id="btnRunQuery" onclick="btnRunQuery_Click
</TR>
</TABLE>
</FONT></strong>
<br>
<strong>Results of:</strong>
<asp:datagrid id="ReceiptsDataGrid" runat="server" BorderWidth="3" CellSpacing="1" CellPadding="1"
Height="144px" Width="500px" OnItemDataBound="ReceiptsD
HeaderStyle-Font-Bold="Tru
font-size="XX-Small" font-names="Verdana" BorderColor="#CCCC99" AutoGenerateColumns="False
<AlternatingItemStyle Wrap="False" BackColor="PaleGoldenrod">
<ItemStyle Wrap="False" BackColor="Beige"></ItemSt
<HeaderStyle Font-Size="14px" Font-Bold="True" ForeColor="White" BackColor="#954896"></Head
<Columns>
<asp:BoundColumn DataField="RC_PAYMNB" HeaderText="Payment Number "></asp:BoundColumn>
<asp:BoundColumn DataField="RC_CASHNB" HeaderText="Cash Number"></asp:BoundColumn>
<asp:BoundColumn DataField="RC_DATE" HeaderText="Date"></asp:Bo
<asp:BoundColumn DataField="RC_DATA" Visible="False" HeaderText="Data"></asp:Bo
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button CommandName="View" Text="View" Runat="server" ID="Button1"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button CommandName="Print" Text="Print" Runat="server" ID="Button2"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid></P></form>
</BODY>
</HTML>
.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Drawing;
using System.Data.Common;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls
using Microsoft.Data.Odbc;
namespace MSPOS
{
/// <summary>
/// Summary description for Receipts.
/// </summary>
public class Receipts : System.Web.UI.Page
{
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
private DataSet ddlDataSet = new DataSet();
private OdbcConnection myConnection = new OdbcConnection("DSN=POS;UI
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
private DataSet ddlDataSet1 = new DataSet();
private DataSet ddlDataSet2 = new DataSet();
protected ActiveUp.WebControls.Activ
protected ActiveUp.WebControls.Activ
private DataSet ddlDataSet3 = new DataSet();
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!Page.IsPostBack)
{
ActiveDateTime3.Date = System.DateTime.Today.Date
ActiveDateTime4.Date = System.DateTime.Today.Date
}
}
#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.Group_RadioButtonList
this.txtCashier.TextChange
this.btnRunQuery.Click += new System.EventHandler(this.b
this.ReceiptsDataGrid.Sele
this.Load += new System.EventHandler(this.P
}
#endregion
public string DecodeReceipt (string szBill)
{
string szNewBill="";
// Create an ASCII encoding.
Encoding ascii = Encoding.ASCII;
Byte[] encodedBytes = ascii.GetBytes(szBill);
foreach (Byte a in encodedBytes)
{
if ( a ==10 || a ==15 ||a==18 ||a ==27)
{}
else if (a == 13)
szNewBill = szNewBill + "\\n";
else
szNewBill = szNewBill +(char) a;
}
return szNewBill;
}
private void txtPayment_TextChanged(obj
{
}
private void txtCashier_TextChanged(obj
{
}
//************************
// Get RC_PAYMND and populate dataset
public DataSet BindRC_PAYMND(string searchstring)
{
OdbcConnection myConnection = new OdbcConnection("DSN=POS;UI
// Populate the ddlDataSet1
myConnection.Open();
string strSQLDDL = @"SELECT RC_PAYMNB FROM TBRECEIPTS WHERE RC_PAYMNB='"+searchstring+
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL,
ddlDataSet1.Clear();
myDataAdapter.Fill(ddlData
myDataAdapter.Dispose();
myDataAdapter = null;
myConnection.Close();
strSQLDDL = null;
return ddlDataSet1;
}
//************************
//************************
// Get RC_CASHND and populate dataset
public DataSet BindRC_CASHND(string searchstring)
{
OdbcConnection myConnection = new OdbcConnection("DSN=POS;UI
// Populate the ddlDataSet2
myConnection.Open();
string strSQLDDL = @"SELECT RC_CASHNB FROM TBRECEIPTS WHERE RC_CASHNB='"+searchstring+
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL,
ddlDataSet2.Clear();
myDataAdapter.Fill(ddlData
myDataAdapter.Dispose();
myDataAdapter = null;
myConnection.Close();
strSQLDDL = null;
return ddlDataSet2;
}
//************************
//************************
// Get RC_CASHND and populate dataset with RC_CASHND and RC_DATE
public DataSet BindRC_DATE()
{
OdbcConnection myConnection = new OdbcConnection("DSN=POS;UI
// Populate the ddlDataSet3
myConnection.Open();
string strSQLDDL = @"SELECT RC_DATE FROM TBRECEIPTS";
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL,
ddlDataSet3.Clear();
myDataAdapter.Fill(ddlData
myDataAdapter.Dispose();
myDataAdapter = null;
myConnection.Close();
strSQLDDL = null;
return ddlDataSet3;
}
//************************
public void ReceiptsDataGrid_ItemDataB
{
if(e.Item.ItemType == ListItemType.AlternatingIt
{
string strValue="Javascript:OpenN
HtmlButton btn=(HtmlButton)(e.Item.Ce
btn.Attributes.Add("Onclic
}
}
//************************
public void ReceiptsDataGrid_ItemComma
{
ListItemType oType = ((ListItemType)e.Item.Item
if(oType == ListItemType.Item || oType == ListItemType.AlternatingIt
{
e.Item.Attributes.Add("onm
e.Item.Attributes.Add("onm
}
if(e.CommandName =="View")
{
string parsedreceipt = null;
parsedreceipt = DecodeReceipt (e.Item.Cells[3].Text);
StringBuilder strAlert = new StringBuilder();
strAlert.Append("<script language=javascript> alert('");
strAlert.Append("Receipt: " + parsedreceipt + "\\n");
strAlert.Append("');</scri
this.RegisterStartupScript
}
}
private void Group_RadioButtonList_Sele
{
}
public void btnRunQuery_Click(object sender, System.EventArgs e)
{
string select_statement = "SELECT RC_PAYMNB, RC_CASHNB, RC_DATE, RC_DATA FROM TBRECEIPTS";
string DateString1 = ActiveDateTime3.Date.Day.T
string DateString2 = ActiveDateTime4.Date.Day.T
Response.Write (DateString1 +"<BR>");
Response.Write (DateString2 +"<BR>");
switch (Group_RadioButtonList.Sel
{
case 0:
select_statement += " Where RC_PAYMNB='" + txtPayment.Text + "'";
break;
case 1:
select_statement += " Where RC_CASHNB='" + txtCashier.Text + "'";
break;
case 2:
// select_statement += " Where To_Date(RC_DATE, 'DDMMYYYY') <=To_Date('" + DateString2.ToString("DDMM
Response.Write (select_statement);
break;
}
OdbcConnection myConnection = new
OdbcConnection("DSN=POS;UI
// Populate the ddlDataSet1
myConnection.Open();
string strSQLDDL = select_statement;
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL,
ddlDataSet1.Clear();
myDataAdapter.Fill(ddlData
myDataAdapter.Dispose();
myDataAdapter = null;
myConnection.Close();
ReceiptsDataGrid.DataSourc
ReceiptsDataGrid.DataBind(
}
private void ReceiptsDataGrid_SelectedI
{
}
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
winNEw.Document.body is null or not an object javascript error!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
mathieu_cupryk,
Was it so bad Answer that you're giving it grade C? Can you explain please..
-tushar
Was it so bad Answer that you're giving it grade C? Can you explain please..
-tushar
ASKER
U made several mistakes.
ASKER
Exception Details: System.InvalidCastExceptio
Source Error:
Line 170: {
Line 171: string strValue="Javascript:OpenN
Line 172: Button btn=(Button)(e.Item.Cells[
Line 173: btn.Attributes.Add("Onclic
Line 174:
Source File: c:\inetpub\wwwroot\mspos\r
Stack Trace:
[InvalidCastException: Specified cast is not valid.]
MSPOS.Receipts.ReceiptsDat
System.Web.UI.WebControls.
System.Web.UI.WebControls.
System.Web.UI.WebControls.
System.Web.UI.WebControls.
System.Web.UI.WebControls.
MSPOS.Receipts.btnRunQuery
System.EventHandler.Invoke
System.Web.UI.WebControls.
System.Web.UI.WebControls.
System.Web.UI.Page.RaisePo
System.Web.UI.Page.RaisePo
System.Web.UI.Page.Process
--------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032
Request Details
Session Id: 2tihb33u4wry2p55o0gadp55 Request Type: POST
Time of Request: 10/19/2004 4:11:23 PM Status Code: 500
Request Encoding: Unicode (UTF-8) Response Encoding: Unicode (UTF-8)
Trace Information
Category Message From First(s) From Last(s)
aspx.page Begin Init
aspx.page End Init 0.000069 0.000069
aspx.page Begin LoadViewState 0.000101 0.000032
aspx.page End LoadViewState 0.000463 0.000362
aspx.page Begin ProcessPostData 0.000501 0.000039
aspx.page End ProcessPostData 0.000617 0.000116
aspx.page Begin ProcessPostData Second Try 0.000650 0.000033
aspx.page End ProcessPostData Second Try 0.000681 0.000031
aspx.page Begin Raise ChangedEvents 0.000705 0.000025
aspx.page End Raise ChangedEvents 0.000747 0.000042
aspx.page Begin Raise PostBackEvent 0.000769 0.000022
Unhandled Execution Error
Specified cast is not valid.
at MSPOS.Receipts.ReceiptsDat
at System.Web.UI.WebControls.
at System.Web.UI.WebControls.
at System.Web.UI.WebControls.
at System.Web.UI.WebControls.
at System.Web.UI.WebControls.
at MSPOS.Receipts.btnRunQuery
at System.EventHandler.Invoke
at System.Web.UI.WebControls.
at System.Web.UI.WebControls.
at System.Web.UI.Page.RaisePo
at System.Web.UI.Page.RaisePo
at System.Web.UI.Page.Process
Control Tree
Control Id Type Render Size Bytes (including children) Viewstate Size Bytes (excluding children)
Cookies Collection
Name Value Size
Polls_Question20 101 20
ASP.NET_SessionId 2tihb33u4wry2p55o0gadp55 42
Headers Collection
Name Value
Cache-Control no-cache
Connection Keep-Alive
Content-Length 646
Content-Type application/x-www-form-url
Accept image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpo
Accept-Encoding gzip, deflate
Accept-Language en-us
Cookie Polls_Question20=101; ASP.NET_SessionId=2tihb33u
Host localhost
Referer http://localhost/MSPOS/Receipts.aspx
User-Agent Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)
Form Collection
Name Value
__VIEWSTATE dDwyMDc2ODMyNjU7dDw7bDxpPD
txtPayment
txtCashier
ActiveDateTime3 632337408000000000
ActiveDateTime3_day 19
ActiveDateTime3_month 10
ActiveDateTime3_year 2004
ActiveDateTime4 632337408000000000
ActiveDateTime4_day 19
ActiveDateTime4_month 10
ActiveDateTime4_year 2004
btnRunQuery Run Query
Server Variables
Name Value
ALL_HTTP HTTP_CACHE_CONTROL:no-cach
ALL_RAW Cache-Control: no-cache Connection: Keep-Alive Content-Length: 646 Content-Type: application/x-www-form-url
APPL_MD_PATH /LM/W3SVC/1/Root/MSPOS
APPL_PHYSICAL_PATH C:\Inetpub\wwwroot\MSPOS\
AUTH_TYPE
AUTH_USER
AUTH_PASSWORD
LOGON_USER
REMOTE_USER
CERT_COOKIE
CERT_FLAGS
CERT_ISSUER
CERT_KEYSIZE
CERT_SECRETKEYSIZE
CERT_SERIALNUMBER
CERT_SERVER_ISSUER
CERT_SERVER_SUBJECT
CERT_SUBJECT
CONTENT_LENGTH 646
CONTENT_TYPE application/x-www-form-url
GATEWAY_INTERFACE CGI/1.1
HTTPS off
HTTPS_KEYSIZE
HTTPS_SECRETKEYSIZE
HTTPS_SERVER_ISSUER
HTTPS_SERVER_SUBJECT
INSTANCE_ID 1
INSTANCE_META_PATH /LM/W3SVC/1
LOCAL_ADDR 127.0.0.1
PATH_INFO /MSPOS/Receipts.aspx
PATH_TRANSLATED C:\Inetpub\wwwroot\MSPOS\R
QUERY_STRING
REMOTE_ADDR 127.0.0.1
REMOTE_HOST 127.0.0.1
REMOTE_PORT 4955
REQUEST_METHOD POST
SCRIPT_NAME /MSPOS/Receipts.aspx
SERVER_NAME localhost
SERVER_PORT 80
SERVER_PORT_SECURE 0
SERVER_PROTOCOL HTTP/1.1
SERVER_SOFTWARE Microsoft-IIS/6.0
URL /MSPOS/Receipts.aspx
HTTP_CACHE_CONTROL no-cache
HTTP_CONNECTION Keep-Alive
HTTP_CONTENT_LENGTH 646
HTTP_CONTENT_TYPE application/x-www-form-url
HTTP_ACCEPT image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpo
HTTP_ACCEPT_ENCODING gzip, deflate
HTTP_ACCEPT_LANGUAGE en-us
HTTP_COOKIE Polls_Question20=101; ASP.NET_SessionId=2tihb33u
HTTP_HOST localhost
HTTP_REFERER http://localhost/MSPOS/Receipts.aspx
HTTP_USER_AGENT Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)