Replies
hi mike, I create a demo for u, when u run it I hard coded a break point when u hover over the control u wil see that it is null. I need tyur email address so I can send directly to you?
hi Michael, I have another problem I got the template to load, by storing the data table in memory (session), and it loads fine after postback, now have another problem. The template contains control, a usercontrol is one of the many controls it contains (see below 'UserControl'), now the problem is this, when rowInitialize, and or when Page_Load occurs, and it calls the Usercontrols Page_Load event, the controls (see below 'lblHeader', 'grdLabResults') are null, why is this shouldn't this be automatic, when the controls have been created as I have done below in the Usercontrol page file, also see my code-behind file as well.
UserControl (LabResults)
<asp:Label ID="lblHeader" runat="server" Text="" Font-Size="XX-Large"></asp:Label>
</div>
</div>
<AlternatingRowStyle BackColor="#F7F7F7" />
<Columns>
<asp:BoundField DataField="Item Name" HeaderText="Item Name" />
<asp:BoundField DataField="Order Name" HeaderText="Order Name" />
<asp:TemplateField HeaderText="Previous">
<ItemTemplate>
<asp:ImageButton ID="imgPrev" runat="server" CommandName="Previous" CommandArgument='<%# string.Format("{0}%{1}%{2}", Eval("OrderID"), Eval("Arrival Date"), Eval("Item Name")) %>' />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Description">
<ItemTemplate>
<asp:ImageButton ID="imgDesc" runat="server" CommandName="Description" CommandArgument='<%# Eval("Value") %>' />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:BoundField DataField="Value" HeaderText="Value" />
<asp:BoundField DataField="H/L" HeaderText="H/L" />
<asp:BoundField DataField="Range" HeaderText="Range" />
<asp:BoundField DataField="OrderID" HeaderText="OrderID" Visible="False" />
<asp:BoundField DataField="Arrival" HeaderText="Arrival" Visible="False" />
</Columns>
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" Height="30px" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" Height="20px" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<SortedAscendingCellStyle BackColor="#F4F4FD" />
<SortedAscendingHeaderStyle BackColor="#5A4C9D" />
<SortedDescendingCellStyle BackColor="#D8D8F0" />
<SortedDescendingHeaderStyle BackColor="#3E3277" />
</asp:GridView>
{
{
try
{
this.FillLabResultsGrid(); // put a break point here u will see that 'lblHeader' and 'grdLabResults' is null
}
catch (Exception ex)
{
Common.CommonFacade.CommonFacadeAccess.LogError(ex, this._UserID);
}
}
{
#region "Variables"
private ModalPopupExtender _ModalMainPopupExtender = new ModalPopupExtender();
private Panel _PanelPopupControl = new Panel();
private HtmlGenericControl _div1 = new HtmlGenericControl("div");
private HtmlGenericControl _div2 = new HtmlGenericControl("div");
private UserControl _ucMainUserControl = null;
private Button _btnOkControl = new Button();
{
get { return _MyParentForm; }
}
public ImageButton BtnTargetControl
{
get { return _btnTargetControl; }
}
{
get { return _ModalMainPopupExtender; }
}
{
get { return _PanelPopupControl; }
}
{
get { return _div1; }
}
{
get { return _div2; }
}
{
get { return _ucMainUserControl; }
set { _ucMainUserControl = value; }
}
{
get { return _btnOkControl; }
}
{
get { return _ListAdditionalContainerControls; }
}
{
: this()
{
_ucMainUserControl = uc;
_MyParentForm = myParentForm;
}
{
BtnTargetControl.ID = "btnTargetControl";
ModalMainPopupExtender.PopupControlID = "PanelPopupControl";
ModalMainPopupExtender.OkControlID = "btnOkControl";
ModalMainPopupExtender.DropShadow = true;
PanelPopupControl.HorizontalAlign = HorizontalAlign.Center;
PanelPopupControl.BackColor = Color.White;
PanelPopupControl.Height = new Unit(450);
PanelPopupControl.Width = new Unit(400);
PanelPopupControl.Style.Add(HtmlTextWriterStyle.Display, "none");
PanelPopupControl.Style.Add(HtmlTextWriterStyle.BorderStyle, "solid");
PanelPopupControl.Style.Add(HtmlTextWriterStyle.BorderWidth, "2px");
PanelPopupControl.Style.Add(HtmlTextWriterStyle.BorderColor, "black");
PanelPopupControl.Style.Add("align-items", "center");
PanelPopupControl.Controls.Add(Div1);
PanelPopupControl.Controls.Add(Div2);
{
ucMainUserControl = new UserControl();
var divInner = new HtmlGenericControl("div");
divInner.Style.Add(HtmlTextWriterStyle.TextAlign, "center");
divInner.Style.Add("align-items", "center");
ucMainUserControl.Controls.Add(divInner);
}
Div1.Style.Add(HtmlTextWriterStyle.Height, "400px");
Div1.Controls.Add(ucMainUserControl);
Div2.Controls.Add(BtnOkControl);
}
{
container.Controls.Add(BtnTargetControl);
{
foreach (var c in _ListAdditionalContainerControls)
container.Controls.Add(c);
}
container.Controls.Add(PanelPopupControl);
}
}
Hi Michael,
yes I know I have to re-set the cells template after postback but which event do I use to do this, and I don't have to make repeated database calls to do this do I? Cuz it uses value from a table to determine which cell is assign the template or not?