Dear Experts,

New to C# ,
My page is in ASP.Net with C# coding,
I am getting this error, while debuging. Your help would be appriciated.
----------

System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Source="App_Web_print.aspx.c0a41cfd.e1sjotnx"
StackTrace:
at ASP.soft_reports_print_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\Inetpub\wwwroot\ictm\soft\Reports\print.aspx:line 15
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:

Again thanks for your time and help

----------------

<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Register TagPrefix="auth" Namespace="ICTMLogging" Assembly="ictmlogging" %>
<%@ Import Namespace="ICTMLogging" %>
<%
ICTMLogging log=null;

try{log=(ICTMLogging)Session.Contents["log"];}catch(Exception ex){
	Console.Write(ex.ToString());
    }
    string proj_id = Session.Contents["proj_id"].ToString();
    string app = Session.Contents["app_id"].ToString();
    string app_id = app;
    string project_id = (Session.Contents["project_id"] != null) ? Session.Contents["project_id"].ToString() : "";
    string comp_id = Session.Contents["comp_id"].ToString();

    int i = 0;

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function selhead(theElement) {
	var e=document.getElementById('atitle');
	e.checked=theElement.checked;
	e=document.getElementById('ptitle');
	e.checked=theElement.checked;
}
function sel(theElement) {
	
     var theForm = theElement.form, z = 0;
	 var t=theForm["no"].value;
	 var tx='';
	
	for (i=1;i<=t;i++)
	{
		var el=document.getElementById('print_'+i);
		if (el.type=='checkbox')
			el.checked=theElement.checked;
	}
}
function prev(fn,no){
	var frm=document.getElementById('frm');
	frm.target="_blank";
	frm.action='prev1.aspx?n='+no;
	frm.submit();
}
function final(){
	var frm=document.getElementById('frm');
	frm.target="_blank";
	frm.action='print_first.aspx';
	frm.submit();
}
function sp() {
	var frm=document.getElementById('frm');
	frm.target="_self";
	frm.action='save_print.aspx';
	frm.submit();
}
</script>
<link href="../../CSS/ee.css" rel="stylesheet" type="text/css">
</head>


<body>
<p class="head_style" >Reports</p>





<%
string at,pt,pnot;
string at_al,pt_al,pnot_al,ctitle_al;
at=pt=pnot=at_al=pt_al=pnot_al=ctitle_al="";
OleDbConnection conn=new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["MM_CONNECTION_STRING_ictmdb"]);
conn.Open();
OleDbCommand comm=null;
OleDbDataReader dr=null;
    
comm=new OleDbCommand("print_pack.check_print",conn);
comm.CommandType=CommandType.StoredProcedure;
OleDbParameter prm=comm.Parameters.Add("@proj_id",OleDbType.VarChar);
prm.Value=proj_id;
prm=comm.Parameters.Add("@app",OleDbType.Double);
prm.Value=app;
bool prt=false;
comm.ExecuteNonQuery();
    
string title="",uid="",uname="";
comm=new OleDbCommand("select ptitle_print,ptitle_align,atitle_print,atitle_align,pno_print,pno_align,"+
 	" ctitle_align from ictm_print_header prt where prt.proj_id='"+proj_id+"'",conn);
dr=comm.ExecuteReader();
if(dr.Read()){
	at=dr["atitle_print"].ToString();
	at_al=dr["atitle_align"].ToString();
	pt=dr["ptitle_print"].ToString();
	pt_al=dr["ptitle_align"].ToString();
	pnot=dr["pno_print"].ToString();
	pnot_al=dr["pno_align"].ToString();
	ctitle_al=dr["ctitle_align"].ToString();
}
dr.Close();

comm=new OleDbCommand("select * from ictm_project_detail where proj_id='"+proj_id+"'",conn);
dr=comm.ExecuteReader();
if(dr.Read()){
	title=(dr["title"].ToString());
    uid = (string)dr["user_id"].ToString().Trim();
}
dr.Close();   
    
    
    //----------  Get Username from employees table
    
comm = new OleDbCommand("select * from ictm_user where company_id='" + Session.Contents["comp_id"].ToString() + "' and user_id='"+ uid +"' ", conn);
dr = comm.ExecuteReader();
if (dr.Read()) { uname = (string)dr["user_name"].ToString().Trim(); }  
dr.Close();     

comm=new OleDbCommand("select * from ictm_project where project_id='"+project_id+"'",conn);
dr=comm.ExecuteReader();
string ptitle="";
if(dr.Read()){
ptitle=dr["description"].ToString();
}
dr.Close();

string fpath="";
fpath = Request.PhysicalApplicationPath.ToString();
fpath = fpath + "soft\\tmp\\reports\\final\\";

if (File.Exists(fpath + proj_id.ToString() + ".PDF"))
{ prt = true; }
%>




<form action="print_first.aspx" method="post"   target="_blank" name="frm">

<input type="hidden" name="uname" value="<%=uname%>">

<%    
comm=new OleDbCommand("select 1 rno,comp_name description from ictm_company where company_id='"+comp_id+"' "+
	"union select 2 rno,description from ictm_project where project_id='"+project_id+"' "+
	"union select 3 rno,description from ictm_application where app_id="+app_id+
	"union select 4 rno,title from ictm_project_detail where proj_id='"+proj_id+"' order by rno",conn);
dr=comm.ExecuteReader();
if (dr.Read()){
%>

<input type="hidden" name="title" value="<%=title%>">
<input type="hidden" name="comp" value="<%=dr["description"]%>">
<input type="hidden" name="ctitle" value="<%=ptitle%>">
<% dr.Read();%>
<input type="hidden" name="project" value="<%=dr["description"]%>">
<% dr.Read();%>
<input type="hidden" name="app_name" value="<%=dr["description"]%>">
<% dr.Read();
String tmp1="";
try{
	tmp1=dr["description"].ToString();
}catch(Exception ex){if(log!=null) log.log(ex.ToString());}
%>
<input type="hidden" name="application" value="<%=tmp1%>">
<% 
}dr.Close();%>
<table  border="0" cellpadding="4" cellspacing="0" >
<tr>
<td><input type="Button" value="Print the PDF"  onClick="final()"></td>
<td><input type="button" name="Button" value="Save Print Setup "  onClick="sp()"></td>
<%if(prt){%>
<td><input type="button" onClick="window.open('/ictm/soft/tmp/reports/final/<%=proj_id%>.pdf')" value="Last Report"></td>
<%}%>
</tr>
</table>


<h4>Page Header Setup</h4>
<table border="1" cellpadding="3" cellspacing="0">
  <tr class="print_head">
    <td class="print_head" width="150" rowspan="2" align="left" valign="middle" nowrap> &nbsp; Description </td>
    <td class="print_head" rowspan="2" align="center" valign="middle" nowrap> Print<br>        
      <input type="checkbox" name="checkbox2" value="checkbox" style="border-width:0 " onClick="selhead(this)">    </td>
    <td class="print_head" colspan="3" align="center" valign="top" nowrap> Alignment </td>
  </tr>
  <tr >
    <td width="26" nowrap class="print_head"> Left </td>
    <td width="25" nowrap class="print_head"> Center </td>
    <td width="25" nowrap class="print_head"> Right </td>
  </tr>
  <tr align="center">
    <td align="left" class="print_data">  &nbsp; <b>Company Name</b> </td>
    <td class="print_data">  <input style="border-width:0 " name="ctitle" type="checkbox" id="ctitle" value="Y" checked disabled>      </td>
    <td class="print_data">  <input style="border-width:0 " name="ctitle_al" type="radio" value="1" <%=(ctitle_al=="1")?"checked":""%>>      </td>
    <td class="print_data">  <input style="border-width:0 " name="ctitle_al" type="radio" value="2"<%=(ctitle_al=="2")?"checked":""%>>      </td>
    <td class="print_data">  <input style="border-width:0 " name="ctitle_al" type="radio" value="3"<%=(ctitle_al=="3")?"checked":""%>>      </td>
  </tr>
  <tr align="center">
    <td align="left" class="print_data">  &nbsp; <b>Project Title</b> </td>
    <td class="print_data">  <input style="border-width:0 " name="ptitle" type="checkbox" id="ptitle" value="Y" <%=(pt=="Y")?"checked":""%>>      </td>
    <td class="print_data">  <input style="border-width:0 " name="ptitle_al" type="radio" value="1"  <%=(pt_al=="1")?"checked":""%>>      </td>
    <td class="print_data">  <input name="ptitle_al" type="radio" value="2" style="border-width:0 " <%=(pt_al=="2")?"checked":""%>>    </td>
    <td class="print_data">  <input style="border-width:0 " name="ptitle_al" type="radio" value="3" <%=(pt_al=="3")?"checked":""%>>      </td>
  </tr>
  <tr align="center">
    <td align="left" class="print_data">  &nbsp; <b>Application Title</b> </td>
    <td class="print_data">  <input style="border-width:0 " name="atitle" type="checkbox" id="atitle" value="Y" <%=(at=="Y")?"checked":""%>>      </td>
    <td class="print_data">  <input style="border-width:0 " name="atitle_al" type="radio" value="1"  <%=(at_al=="1")?"checked":""%>>      </td>
    <td class="print_data">  <input name="atitle_al" type="radio" value="2"  style="border-width:0 " <%=(at_al=="2")?"checked":""%>>    </td>
    <td class="print_data">  <input style="border-width:0 " name="atitle_al" type="radio" value="3" <%=(at_al=="3")?"checked":""%> >      </td>
  </tr>
</table>




<h4>Page Footer Setup</h4>
<table border="1" cellpadding="3" cellspacing="0">
  <tr>
    <td width="150" rowspan="2" align="left" valign="middle" nowrap class="print_head">  &nbsp;  Description </td>
    <td rowspan="2" align="center" valign="middle" nowrap class="print_head"> Print <br>
    </td>
    <td colspan="3" align="center" valign="top" nowrap class="print_head"> Alignment </td>
  </tr>
  <tr >
    <td width="26" nowrap class="print_head"> Left </td>
    <td width="25" nowrap class="print_head"> Center </td>
    <td width="25" nowrap class="print_head"> Right </td>
  </tr>
  <tr align="center">
    <td align="left" class="print_data">  &nbsp; <b>Page No </b></td>
    <td class="print_data">
      <input style="border-width:0 " name="Pno" type="checkbox" id="Pno" value="Y" <%=(pnot=="Y")?"checked":""%>>    </td>
    <td class="print_data">
      <input style="border-width:0 " name="pno_al" type="radio" value="1"  <%=(pnot_al=="1")?"checked":""%>>    </td>
    <td class="print_data">
      <input name="pno_al" type="radio" value="2" style="border-width:0 " <%=(pnot_al=="2")?"checked":""%>>    </td>
    <td class="print_data">
      <input style="border-width:0 " name="pno_al" type="radio" value="3"  <%=(pnot_al=="3")?"checked":""%>>    </td>
  </tr>
</table>





<h4>Page Setup</h4>

<table border="1" cellpadding="3" cellspacing="0">
  <tr valign="top">
    <td rowspan="2" nowrap class="print_head" align="left" valign="middle"> Page Name </td>
    <td rowspan="2" nowrap class="print_head" align="center"> Print ? <br>
        <input style="border-width:0 " name="checkbox" type="checkbox"  onClick="sel(this)" value="checkbox" checked>
    </td>
    <td rowspan="2" nowrap class="print_head" align="center" valign="top"> Back <br /> Color </td>
    <td colspan="2" nowrap class="print_head" align="center" valign="middle"> Orientation </td>
    <td rowspan="2" nowrap class="print_head" align="center" valign="middle"> Page Size  </td>
    <td colspan="4" nowrap class="print_head" align="center"> Margin [Inches] </td>
    <td rowspan="2" nowrap class="print_head" align="left" valign="middle"> Scaling </td>
    <td rowspan="2" nowrap class="print_head" align="left" valign="middle"> Preview </td>
  </tr>
  <tr >
    <td nowrap class="print_head" align="left">Portrait</td>
    <td nowrap class="print_head" align="left">Landscape</td>
    <td nowrap class="print_head" align="center"> Left </td>
    <td nowrap class="print_head" align="center"> Right </td>
    <td nowrap class="print_head" align="center"> Top </td>
    <td nowrap class="print_head" align="center"> Bottom </td>
    </tr>
<%
comm=new OleDbCommand("select prt.proj_id,prt.app_id,prt.sub_id,prt.print,prt.orientation,prt.pagesize,prt.lm,prt.back, " +
						"prt.rm,prt.tm,prt.bm,prt.scaling,mas.FILE_NAME,mas.description from ictm_print prt,ictm_print_master mas  " +
						"where prt.app_id=mas.APP_ID and prt.sub_id=mas.SUB_ID and prt.proj_id='"+proj_id+"' and prt.app_id="+app+" order by prt.sub_id",conn);
dr=comm.ExecuteReader();
while(dr.Read()){
i++;
%>
  <tr>
    <td class="print_data" align="left" valign="middle" nowrap> <b><%=dr["description"]%></b>&nbsp;
	<input type="hidden" name="fn_<%=i%>" value="<%=dr["file_name"]%>">
	<input name="sub_id_<%=i%>" type="hidden" id="sub_id_<%=i%>" value="<%=dr["sub_id"]%>">	
	</td>
    <td class="print_data" align="center"><input name="print_<%=i%>" type="checkbox" value="Y" <%=dr["print"].ToString()=="Y"?"checked":""%> style="border-width:0 "></td>
    <td class="print_data">
      <div align="center">
        <input name="back_<%=i%>" type="checkbox" id="back_<%=i%>" value="Y" <%=dr["back"].ToString()=="Y"?"checked":""%> style="border-width:0 ">
</div></td>
    <td nowrap class="print_data"><div align="center">
      <input name="ori_<%=i%>" type="radio" style="border-width:0 " value="1" <%=dr["orientation"].ToString()=="1"?"checked":""%>>
    </div></td>
    <td nowrap class="print_data"><div align="center">
      <input name="ori_<%=i%>" type="radio" value="2" style="border-width:0 "<%=dr["orientation"].ToString()=="2"?"checked":""%>>
    </div></td>
    <td nowrap class="print_data">
	<% int pg=9;
	try{
		pg=Convert.ToInt32(dr["pagesize"]);
	}catch(Exception ex){if(log!=null) log.log(ex.ToString());	}
	%>
      <select name="pg_<%=i%>" style="width:160">
        <option value="1" <%=(pg==1)?"selected":""%>>Letter 8 1/2 x 11 in</option>
        <option value="2" <%=(pg==2)?"selected":""%>>Letter Small 8 1/2 x 11 in</option>
        <option value="3" <%=(pg==3)?"selected":""%>>Tabloid 11 x 17 in</option>
        <option value="4" <%=(pg==4)?"selected":""%>>Ledger 17 x 11 in</option>
        <option value="5" <%=(pg==5)?"selected":""%>>Legal 8 1/2 x 14 in</option>
        <option value="6" <%=(pg==6)?"selected":""%>>Statement 5 1/2 x 8 1/2 in</option>
        <option value="7" <%=(pg==7)?"selected":""%>>Executive 7 1/2 x 10 1/2 in</option>
        <option value="8" <%=(pg==8)?"selected":""%>>A3 297 x 420 mm</option>
        <option value="9" <%=(pg==9)?"selected":""%>>A4 210 x 197 mm</option>
        <option value="10" <%=(pg==10)?"selected":""%>>A4 Small 210 x 297 mm</option>
        <option value="11" <%=(pg==11)?"selected":""%>>A5 148 x 210 mm</option>
        <option value="12" <%=(pg==12)?"selected":""%>>B4 250 x 354 mm</option>
        <option value="13" <%=(pg==13)?"selected":""%>>B5 182 x 257 mm</option>
        <option value="14" <%=(pg==14)?"selected":""%>>Folio 8 1/2 x 13 in</option>
        <option value="15" <%=(pg==15)?"selected":""%>>Quarto 215 x 275 mm</option>
        <option value="16" <%=(pg==16)?"selected":""%>>10 x 14 in</option>
        <option value="17" <%=(pg==17)?"selected":""%>>11 x 17 in</option>
        <option value="18" <%=(pg==18)?"selected":""%>>Note 8 1/2 x 11 in</option>
        <option value="24" <%=(pg==24)?"selected":""%>>C size sheet</option>
        <option value="25" <%=(pg==25)?"selected":""%>>D size sheet</option>
        <option value="26" <%=(pg==26)?"selected":""%>>E size sheet</option>
      </select>
	</td>
    <td nowrap class="print_data"><div align="center">
      <input name="lm_<%=i%>" type="text" value="<%=dr["lm"]%>" size="4">      
    </div></td>
    <td nowrap class="print_data"><div align="center">
      <input name="rm_<%=i%>" type="text" value="<%=dr["rm"]%>" size="4">
    &nbsp; </div></td>
    <td nowrap class="print_data"><div align="center">
      <input name="tm_<%=i%>" type="text" value="<%=dr["tm"]%>" size="4">
    &nbsp; </div></td>
    <td nowrap class="print_data"><input name="bm_<%=i%>" type="text" value="<%=dr["bm"]%>" size="4"></td>
    <td nowrap class="print_data"><input name="scaling_<%=i%>" type="text" id="scaling_<%=i%>" value="<%=dr["scaling"]%>" size="5"> 
      % </td>
    <td nowrap class="print_data"><div align="center"><a href="javascript:prev('<%=dr["sub_id"]%>','<%=i%>')">Preview</a></div></td>
  </tr>
<%
}
%>
</table>
<br>
<input type="hidden" name="no" value="<%=i%>">

</form>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.