I have a weird problem that should have been very easy. I have a form with a lot of entries. When I try to pull a value after post back I get a NullRef. I turned tracing on and it shows that they are there, it shows the value I am expecting, but for some reason I cant retrive it. The code is long so I have shortened it. Any help is very appreciated.
David
David
Code:
<%@ Page Language="C#" Trace="true" %>
<script Language="C#" runat="server">
public PHP.OrderedMap pckarr = new PHP.OrderedMap();
public string qry;
public System.Data.DataTable rlt;
public PHP.OrderedMap row;
public System.Data.Odbc.OdbcConnection MyConnection = new System.Data.Odbc.OdbcConnection("DSN=###");
public double pcount = 0;
protected void Page_Load(Object Source, EventArgs E)
{
if (IsPostBack)
{
Response.Write("Table Updated<BR>");
update_table("Video");
update_table("HSD");
update_table("Phone");
}
}
public void update_table(string type)
{
string check = "";
MyConnection.Open();
pckarr.Clear();
qry = "SELECT * FROM packages WHERE status = 'active' AND (dept = 'disco' || dept = '" + type + "') ORDER BY level";
rlt = PHP.MySQLSupport.Query(qry, MyConnection);
while(PHP.TypeSupport.ToBoolean(row=PHP.MySQLSupport.FetchArray(rlt, 0)))
{
pckarr[row["package"].ToString()] = 0;
}
foreach (string package in pckarr)
{
foreach (string packageb in pckarr)
{
foreach (string packagec in pckarr)
{
string formName = package + packageb + packagec;
if (Request.Form.[formName] != String.Empty)
{
string val = Request.Form[formName].ToString();
Response.Write(val);
}
}
}
}
MyConnection.Close();
}
public void draw_grid()
{
MyConnection.Open();
string cqry;
System.Data.DataTable crlt;
PHP.OrderedMap crow;
int count;
type = "Phone";
Response.Write("<font size=3><BR><B>Phone</B><BR>");
pckarr.Clear();
qry = "SELECT COUNT(id) AS count FROM packages WHERE status = 'active' AND (dept = 'disco' || dept = '" + type + "')";
rlt = PHP.MySQLSupport.Query(qry, MyConnection);
row=PHP.MySQLSupport.FetchArray(rlt, 0);
pcount = PHP.TypeSupport.ToInt32(row["count"].ToString());
qry = "SELECT * FROM packages WHERE status = 'active' AND (dept = 'disco' || dept = '" + type + "') ORDER BY level";
rlt = PHP.MySQLSupport.Query(qry, MyConnection);
while(PHP.TypeSupport.ToBoolean(row=PHP.MySQLSupport.FetchArray(rlt, 0)))
{
pckarr[row["package"].ToString()] = 0;
}
Response.Write("<table>");
Response.Write("<tr><td>TO &rArr </td>");
foreach (string package in pckarr)
{
Response.Write("<td colspan = \"" + pcount + "\">" + package + "</td>");
}
Response.Write("<tr><td>WANT &rArr </td>");
for(int i = 0; i < pcount; i++)
{
foreach (string package in pckarr)
{
Response.Write("<td>" + package + "</td>");
}
}
Response.Write("</tr><tr><td>FROM &dArr </td>");
foreach (string package in pckarr)
{
foreach (string packageb in pckarr)
{
Response.Write("<td> </td>");
}
}
Response.Write("</tr>");
foreach (string package in pckarr)
{
if(package != "Disconnect")
{
Response.Write("<tr><td>" + package + "</td>");
foreach (string packageb in pckarr)
{
foreach (string packagec in pckarr)
{
cqry = "SELECT commission FROM savcmssn, packages a, packages b, packages c WHERE start = a.id AND a.package = '" + package + "' AND want = b.id AND b.package = '" + packagec + "' AND end = c.id AND c.package = '" + packageb + "'";
crlt = PHP.MySQLSupport.Query(cqry, MyConnection);
if(crlt.Rows.Count > 0)
{
crow = PHP.MySQLSupport.FetchArray(crlt, 0);
Response.Write("<td><input type=\"text\" size=\"1\" name=\"" + package + packageb + packagec + " \" value=\"" + crow["commission"].ToString() + "\"></td>");
}else
{
Response.Write("<td><input type=\"text\" size=\"1\" name=\"" + package + packageb + packagec + "\" value= ></td>");
}
}
}
Response.Write("</tr>");
}
}
Response.Write("</tr><tr><td colspan=\"200%\"><input type=\"submit\" value=\"Submit\"></td></tr>");
Response.Write("</table>");
MyConnection.Close();
}
</script>
<html>
<head>
<link rel="stylesheet" href="../../css/default.css" type="text/css">
</head>
<body>
<%Functions.MyFunctions.do_login("commission_matrix.aspx");%>
<form method="post" runat="server">
<%
draw_grid();
%>
</form>
</body>
</html>