As per topic, if any possible to access entity column field values(already been assign from query to DataList and done in rendered)?
I've tried to used the pattern method utilised in runtime itemdatabound event and It only gave with result "null".
From Point as "dynamic SectionGroup = (Object)JobListItem.DataItem;" where it return nothing.
<h1 id="SectionHeader" runat="server" style="color:blue;margin-left:16px"></h1>
<div id="JobProgressSectionHandle">
<div id="JobProgressInSection" runat="server">
</div>
</div>
<table>
<tr>
<td>
<asp:Button ID="PrintsectionButton" runat="server" Text="Print" Width="85px" Height="40px" ClientIDMode="Static" OnClick="PrintsectionButton_Click" />
</td>
</tr>
</table>
<br />
</ItemTemplate>
</asp:DataList>
</div>
</ItemTemplate>
Query Assign to DataList "JobList" before JobProgressList:protected void JobList_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
var querysectionlist = (from query in timesheet.MPTimeSheets
where query.PTWON == JobNumberHolder & query.PTCCC == MachineProdId
& query.PTCDATE >= StartDateHolder & query.PTCDATE <= EndDateHolder
select new {
query.PTWON,
query.SectionGroup_Id,
query.PTITEM,
}).Distinct().ToList();
DataList JobProgressList = (DataList)e.Item.FindControl("JobProgressList");
if (JobProgressList != null)
{
JobProgressList.DataSource = querysectionlist;
JobProgressList.DataBind();
}
}
}
Code Behind (When Press on 'PrintsectionButton' button (Child button on DataList JobProgressList):
protected void PrintsectionButton_Click(object sender, EventArgs e)
{
try
{
Button PrintButton = sender as Button;
DataListItem ListItem = PrintButton.NamingContainer as DataListItem;
DataList JobProgressList = (DataList)this.JobList.Controls[1].FindControl("JobProgressList");
var MachineIdHolder = Convert.ToInt32(this.CostCentreDropDown.SelectedValue);
DateTime StartDateHolder = DateTime.ParseExact(this.StartPrintDate.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
DateTime EndDateHolder = DateTime.ParseExact(this.EndPrintDate.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
var StartDateDay = (StartDateHolder.Day < 10) ? "0" + StartDateHolder.Day.ToString() : StartDateHolder.Day.ToString();
var StartDateMonth = (StartDateHolder.Month < 10) ? "0" + StartDateHolder.Month.ToString() : StartDateHolder.Month.ToString();
var StartDateValue = Convert.ToInt32(StartDateHolder.Year.ToString() + StartDateMonth + StartDateDay);
var EndDateDay = (EndDateHolder.Day < 10) ? "0" + EndDateHolder.Day.ToString() : EndDateHolder.Day.ToString();
var EndDateMonth = (EndDateHolder.Month < 10) ? "0" + EndDateHolder.Month.ToString() : EndDateHolder.Month.ToString();
var EndDateValue = Convert.ToInt32(EndDateHolder.Year.ToString() + EndDateMonth + EndDateDay);
DataListItem JobListItem = ListItem.Parent.NamingContainer as DataListItem;
if (JobListItem.ItemType == ListItemType.Item || JobListItem.ItemType == ListItemType.AlternatingItem)
{
dynamic SectionGroup = (Object)JobListItem.DataItem;
var SectionId = (String)SectionGroup.SectionGroup_Id;
File.WriteAllText(@"C:\checkprint.txt", "");
File.AppendAllText(@"C:\checkprint.txt", "Check :" + SectionId);
}
}
catch(Exception ex)
{
}
}
My Question here shoud it be possible to access entity column after runtime (rendered finished)? And I also don't want to use DataKeyName or DataKeyFields because I've create a bundle of same DataList as same time (means I've create two same DataList "JobProgressList" at a time,use DataKeyName will only refers to first DataList ).