
Journal Marxist Hacker 42's Journal: Going insane, need help, Ask Slashdot ASP.NET 3.5 5
This is driving me nuts.
I have a recordset, on an ASP.NET page with C# back end. The following code snippet creates a dataset of two rows, then uses a DataList to output those two rows, supposedly, except it doesn't. The label lblTedTest confirms that I've got two rows in the Datatable, but the DataList is only outputing the first.:
//If ITA's are present, get user information for each ITA
if (ITADS.DefinedITAs.Count > 0)
{
DataTable dtITAContact = new DataTable();
dtITAContact.Columns.Add("State", typeof(string));
dtITAContact.Columns.Add("Organization", typeof(string));
dtITAContact.Columns.Add("Description", typeof(string));
dtITAContact.Columns.Add("FullName", typeof(string));
dtITAContact.Columns.Add("URL", typeof(string));
dtITAContact.Columns.Add("Phone", typeof(string));
dtITAContact.Columns.Add("E-Mail", typeof(string));
dtITAContact.Columns.Add("NewLEA Message", typeof(string));
dtITAContact.Columns.Add("OrgType", typeof(int));
DataRow dr;
int n = 0;
while (n < ITADS.DefinedITAs.Count)
{
if (ITADS.DefinedITAs[n].ItaPrimaryContactId <= 0)
{
n++;
continue;
}
dr = dtITAContact.NewRow();
UserManagementDataSet CMTUserDS = Svcref.GetUserInformation(ITADS.DefinedITAs[n].ItaPrimaryContactId);
if (CMTUserDS.UserInfo.Count == 0)
{
n++;
continue;
}
result = Svcref.GetDefinedStates(out AllStates);
pnlITAContactInformation.Visible = true;
//Old Order: State, FullName, URL, Phone, E-mail, NewLEA Message, Organization
//New Order: Organization, Description, Contact Person, URL, Phone, E-mail
if (!string.IsNullOrEmpty(CMTUserDS.UserInfo[0].State))
dr[0] = AllStates.FindByStateAbbreviation(CMTUserDS.UserInfo[0].State).Name;
else
dr[0] = "";
dr[2] = ITADS.DefinedITAs[n].Description;
dr[3] = CMTUserDS.UserInfo[0].FirstName + " " + CMTUserDS.UserInfo[0].LastName;
dr[4] = "<a href='http://" + ITADS.DefinedITAs[n].URL + "' target=_blank>" + ITADS.DefinedITAs[n].URL + "</a>";
dr[5] = CMTUserDS.UserInfo[0].PhoneNumber.Substring(0,3) + "-" + CMTUserDS.UserInfo[0].PhoneNumber.Substring(3,3) + "-" + CMTUserDS.UserInfo[0].PhoneNumber.Substring(6,4);
dr[6] = CMTUserDS.UserInfo[0].Email
dr[1] = "<B>" + ITADS.DefinedITAs[n].Name + "</B>";
if (ITADS.DefinedITAs[n].AcceptLeas)
{
dr[7] = "Apply as new LEA messagewithappropriatelinks";
}
else
dr[7] = "";
dr[8] = ITADS.DefinedITAs[n].OrgType;
dtITAContact.Rows.Add(dr);
n++;
}
lblTedDebug.Text = System.Convert.ToString(dtITAContact.Rows.Count);
dlITAs.DataSource = dtITAContact.DefaultView;
dlITAs.DataBind();
}
----------------------
Here's the relevant inline code for the Datalist:
<asp:Panel ID="pnlITAContactInformation" runat="server" Visible="false">
<asp:DataList ID="dlITAs" runat="server" Width="100%">
<HeaderTemplate>
<table width="100%" cellpadding="1" cellspacing="1">
<tr>
<td>
</td>
</tr>
<tr>
<td>
<b>For further information on the program in your area:</b><br /><br />
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table width="100%" cellpadding="1" cellspacing="1">
<tr>
<td class="content" vAlign="top" width="107"><b>Contact Person:</b></td>
<td class="content">
<%# DataBinder.Eval(Container.DataItem, "FullName")%>
</td>
</tr>
<tr>
<td class="content" vAlign="top" width="107"><b>Organization:</b></td>
<td class="content">
<%# DataBinder.Eval(Container.DataItem, "Organization")%>
</td>
</tr>
<tr>
<td class="content" vAlign="top" width="107"><b>URL:</b></td>
<td class="content">
<%# DataBinder.Eval(Container.DataItem, "URL")%>
</td>
</tr>
<tr>
<td class="content" vAlign="top" width="107"><b>Phone:</b></td>
<td class="content">
<%# DataBinder.Eval(Container.DataItem, "Phone")%>
</td>
</tr>
<tr>
<td class="content" vAlign="top" width="107"><b>Email:</b></td>
<td class="content">
<%# DataBinder.Eval(Container.DataItem, "Email")%>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td class="content" valign="top" colspan="2" >
<%# DataBinder.Eval(Container.DataItem, "NewLEAMsg")%>
</td>
</tr>
<tr><td> </td></tr>
<tr><td> </td></tr>
</table>
</ItemTemplate>
<HeaderStyle />
<FooterTemplate>
</table>
</FooterTemplate>
</asp:DataList>
</asp:Panel>
-----------------
Anybody have any idea what the hell I've done wrong? Oh, and I should point out- aside from order of fields in the item template, this EXACT SAME CODE is working in production.
I never post programming questions here, but this one is driving me crazy. How the hell did I become incompetent overnight?!?!!?!? And why the heck is the datalist only showing one record when I KNOW there are two?
---------------------
Edit: Answer: Fuck microsoft and their fancy controls. I'll never have more than two records in this recordset, and need to reorder them anyway according to a field I can't sort on, so I'm separating the code into two panels of straight ASP labels that I write to directly with C#.
I have a recordset, on an ASP.NET page with C# back end. The following code snippet creates a dataset of two rows, then uses a DataList to output those two rows, supposedly, except it doesn't. The label lblTedTest confirms that I've got two rows in the Datatable, but the DataList is only outputing the first.:
if (ITADS.DefinedITAs.Count > 0)
{
DataTable dtITAContact = new DataTable();
dtITAContact.Columns.Add("State", typeof(string));
dtITAContact.Columns.Add("Organization", typeof(string));
dtITAContact.Columns.Add("Description", typeof(string));
dtITAContact.Columns.Add("FullName", typeof(string));
dtITAContact.Columns.Add("URL", typeof(string));
dtITAContact.Columns.Add("Phone", typeof(string));
dtITAContact.Columns.Add("E-Mail", typeof(string));
dtITAContact.Columns.Add("NewLEA Message", typeof(string));
dtITAContact.Columns.Add("OrgType", typeof(int));
DataRow dr;
int n = 0;
while (n < ITADS.DefinedITAs.Count)
{
if (ITADS.DefinedITAs[n].ItaPrimaryContactId <= 0)
{
n++;
continue;
}
dr = dtITAContact.NewRow();
UserManagementDataSet CMTUserDS = Svcref.GetUserInformation(ITADS.DefinedITAs[n].ItaPrimaryContactId);
if (CMTUserDS.UserInfo.Count == 0)
{
n++;
continue;
}
result = Svcref.GetDefinedStates(out AllStates);
pnlITAContactInformation.Visible = true;
if (!string.IsNullOrEmpty(CMTUserDS.UserInfo[0].State))
dr[0] = AllStates.FindByStateAbbreviation(CMTUserDS.UserInfo[0].State).Name;
else
dr[0] = "";
dr[2] = ITADS.DefinedITAs[n].Description;
dr[3] = CMTUserDS.UserInfo[0].FirstName + " " + CMTUserDS.UserInfo[0].LastName;
dr[4] = "<a href='http://" + ITADS.DefinedITAs[n].URL + "' target=_blank>" + ITADS.DefinedITAs[n].URL + "</a>";
dr[5] = CMTUserDS.UserInfo[0].PhoneNumber.Substring(0,3) + "-" + CMTUserDS.UserInfo[0].PhoneNumber.Substring(3,3) + "-" + CMTUserDS.UserInfo[0].PhoneNumber.Substring(6,4);
dr[6] = CMTUserDS.UserInfo[0].Email
dr[1] = "<B>" + ITADS.DefinedITAs[n].Name + "</B>";
if (ITADS.DefinedITAs[n].AcceptLeas)
{
dr[7] = "Apply as new LEA messagewithappropriatelinks";
}
else
dr[7] = "";
dr[8] = ITADS.DefinedITAs[n].OrgType;
dtITAContact.Rows.Add(dr);
n++;
}
lblTedDebug.Text = System.Convert.ToString(dtITAContact.Rows.Count);
dlITAs.DataSource = dtITAContact.DefaultView;
dlITAs.DataBind();
}
----------------------
Here's the relevant inline code for the Datalist:
<asp:Panel ID="pnlITAContactInformation" runat="server" Visible="false">
<asp:DataList ID="dlITAs" runat="server" Width="100%">
<HeaderTemplate>
<table width="100%" cellpadding="1" cellspacing="1">
<tr>
<td>
</td>
</tr>
<tr>
<td>
<b>For further information on the program in your area:</b><br
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table width="100%" cellpadding="1" cellspacing="1">
<tr>
<td class="content" vAlign="top" width="107"><b>Contact Person:</b></td>
<td class="content">
<%# DataBinder.Eval(Container.DataItem, "FullName")%>
</td>
</tr>
<tr>
<td class="content" vAlign="top" width="107"><b>Organization:</b></td>
<td class="content">
<%# DataBinder.Eval(Container.DataItem, "Organization")%>
</td>
</tr>
<tr>
<td class="content" vAlign="top" width="107"><b>URL:</b></td>
<td class="content">
<%# DataBinder.Eval(Container.DataItem, "URL")%>
</td>
</tr>
<tr>
<td class="content" vAlign="top" width="107"><b>Phone:</b></td>
<td class="content">
<%# DataBinder.Eval(Container.DataItem, "Phone")%>
</td>
</tr>
<tr>
<td class="content" vAlign="top" width="107"><b>Email:</b></td>
<td class="content">
<%# DataBinder.Eval(Container.DataItem, "Email")%>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td class="content" valign="top" colspan="2" >
<%# DataBinder.Eval(Container.DataItem, "NewLEAMsg")%>
</td>
</tr>
<tr><td> </td></tr>
<tr><td> </td></tr>
</table>
</ItemTemplate>
<HeaderStyle
<FooterTemplate>
</table>
</FooterTemplate>
</asp:DataList>
</asp:Panel>
-----------------
Anybody have any idea what the hell I've done wrong? Oh, and I should point out- aside from order of fields in the item template, this EXACT SAME CODE is working in production.
I never post programming questions here, but this one is driving me crazy. How the hell did I become incompetent overnight?!?!!?!? And why the heck is the datalist only showing one record when I KNOW there are two?
---------------------
Edit: Answer: Fuck microsoft and their fancy controls. I'll never have more than two records in this recordset, and need to reorder them anyway according to a field I can't sort on, so I'm separating the code into two panels of straight ASP labels that I write to directly with C#.
Brackets? (Score:1)
I'm not a coder at all, I mean no way, but I did read it looking for patterns and rhythms. There's like a huge chunk that isn't in brackets, and another place where one of the brackets looks like it is backwards from what it should be. But all that might be pergect, just don't know.
No idea if that will help or not. Stuff looks complicated, no wonder they pay you guys decent pay. Just reading one page of it drives me nuts..it's like it's written all in geek....proly why the first time I used a mouse on the o
Re: (Score:2)
Brackets errors are caught by the compiler, so I doubt it's that.
Heck, this darned IDE wants to help me so much that when copying an ASP label control, it changes the ID to "Label1".
Parse error in footer template (Score:2)
<FooterTemplate>
</table>
</FooterTemplate>
Maybe that's confusing the browser.
Re: (Score:2)
Knowing nothing about ASP.NET (but having played with django and RoR for the hell of it, so I know generally how templates work) the *template tags are parsed by the server: the header is written, the data is plugged into repeating item templates and then the footer is written.
If it is a template problem, my guess is that HeaderStyle should be after (or in?) the HeaderTemplate but before ItemTemplate, but I don't think that would cause the server to write only one item (unless it's throwing an error and com
Re: (Score:2)
Both have data- but thanks for the heads up. I think in my other solution (switching to straight ASP labels after verifying that there will NEVER be more than two items in the dataset) I may have messed that up.