W
Will
Hi Guys -
I am having a problem with one my datalist dlProjectCustomFields that
is 2 layers deep from my primary dlAccounts datalist. All my
datalists populate with the correct values withou any issues except
for the dlProjectCustomFields. All the data within the
dlProjectCustomFields is identical for each new item that is created
in my dlProjects datalist and I am not sure why. I have an
OnItemCreated function that kicks off and has a unique SONumber
associated with each one, and my DataLists when I assign them to the
dlProjectCustomFields are unique, however somewhere along the line all
the values are becoming identical. I have included my asp code, as
well as my dlProjects_OnItemCreated function below. Any assistance is
greatly appreciated as I am stumped. Thanks... Will
protected void dlProjects_OnItemCreated(Object sender,
DataListItemEventArgs e)
{
SqlDataSource sdsCustomValue = new
SqlDataSource(strConnection, "sc_GetCustomFieldValues");
sdsCustomValue.SelectCommandType =
SqlDataSourceCommandType.StoredProcedure;
Parameter pm = new Parameter("AccNumber", TypeCode.Int32,
((DataRowView)e.Item.DataItem).Row.ItemArray[0].ToString());
pm.Direction = ParameterDirection.Input;
sdsCustomValue.SelectParameters.Add(pm);
sdsCustomValue.DataSourceMode = SqlDataSourceMode.DataSet;
DataView dvSOCustomValues =
(DataView)sdsCustomValue.Select(DataSourceSelectArguments.Empty);
DataView dvCurr = new DataView(dvProjectCustomFields.Table);
if (dvSOCustomValues.Count > 0)
{
foreach (DataRowView drv2 in dvSOCustomValues)
{
dvCurr.Table.Rows.Find(drv2.Row["CustomFieldDefinitionKeyID"])[3] =
drv2.Row["CustomFieldValue"];
}
}
DataList dl =
(DataList)e.Item.FindControl("dlProjectCustomFields");
dl.DataSource = new DataView(dvCurr.Table);
dl.DataBind();
}
<aspataList ID="dLAccounts" GridLines="both"
OnItemCreated="dlAccounts_OnItemCreated" runat="server">
<ItemTemplate>
<%# Eval("AccountName") %>
<%# Eval("AccountNumber") %>
<aspataList ID="AccCustomFields" runat="server">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem,
"CustomFieldLabel")%>
<%#DataBinder.Eval(Container.DataItem,"CustomFieldValue")
%>
</ItemTemplate>
</aspataList>
<aspataList ID="dlProjects" runat="server"
DataKeyField="SONumber" OnItemCreated="dlProjects_OnItemCreated">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,"SONumber") %></td>
<%# DataBinder.Eval(Container.DataItem,"BriefDescription")
%>
<aspataList RepeatColumns="2"
ID="dlProjectCustomFields" runat="server">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem,
"CustomFieldLabel")%>
<%#DataBinder.Eval(Container.DataItem,"CustomFieldValue")
</ItemTemplate>
</aspataList>
</ItemTemplate>
</aspataList>
</ItemTemplate>
</aspataList>
I am having a problem with one my datalist dlProjectCustomFields that
is 2 layers deep from my primary dlAccounts datalist. All my
datalists populate with the correct values withou any issues except
for the dlProjectCustomFields. All the data within the
dlProjectCustomFields is identical for each new item that is created
in my dlProjects datalist and I am not sure why. I have an
OnItemCreated function that kicks off and has a unique SONumber
associated with each one, and my DataLists when I assign them to the
dlProjectCustomFields are unique, however somewhere along the line all
the values are becoming identical. I have included my asp code, as
well as my dlProjects_OnItemCreated function below. Any assistance is
greatly appreciated as I am stumped. Thanks... Will
protected void dlProjects_OnItemCreated(Object sender,
DataListItemEventArgs e)
{
SqlDataSource sdsCustomValue = new
SqlDataSource(strConnection, "sc_GetCustomFieldValues");
sdsCustomValue.SelectCommandType =
SqlDataSourceCommandType.StoredProcedure;
Parameter pm = new Parameter("AccNumber", TypeCode.Int32,
((DataRowView)e.Item.DataItem).Row.ItemArray[0].ToString());
pm.Direction = ParameterDirection.Input;
sdsCustomValue.SelectParameters.Add(pm);
sdsCustomValue.DataSourceMode = SqlDataSourceMode.DataSet;
DataView dvSOCustomValues =
(DataView)sdsCustomValue.Select(DataSourceSelectArguments.Empty);
DataView dvCurr = new DataView(dvProjectCustomFields.Table);
if (dvSOCustomValues.Count > 0)
{
foreach (DataRowView drv2 in dvSOCustomValues)
{
dvCurr.Table.Rows.Find(drv2.Row["CustomFieldDefinitionKeyID"])[3] =
drv2.Row["CustomFieldValue"];
}
}
DataList dl =
(DataList)e.Item.FindControl("dlProjectCustomFields");
dl.DataSource = new DataView(dvCurr.Table);
dl.DataBind();
}
<aspataList ID="dLAccounts" GridLines="both"
OnItemCreated="dlAccounts_OnItemCreated" runat="server">
<ItemTemplate>
<%# Eval("AccountName") %>
<%# Eval("AccountNumber") %>
<aspataList ID="AccCustomFields" runat="server">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem,
"CustomFieldLabel")%>
<%#DataBinder.Eval(Container.DataItem,"CustomFieldValue")
%>
</ItemTemplate>
</aspataList>
<aspataList ID="dlProjects" runat="server"
DataKeyField="SONumber" OnItemCreated="dlProjects_OnItemCreated">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,"SONumber") %></td>
<%# DataBinder.Eval(Container.DataItem,"BriefDescription")
%>
<aspataList RepeatColumns="2"
ID="dlProjectCustomFields" runat="server">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem,
"CustomFieldLabel")%>
<%#DataBinder.Eval(Container.DataItem,"CustomFieldValue")
</ItemTemplate>
</aspataList>
</ItemTemplate>
</aspataList>
</ItemTemplate>
</aspataList>