S
Sam Solomon
Dear All,
I am trying to retrieve the value of a DataList cell in a label and assign
it to a Session Variable. For this purpose I am using a method :
private void OpenForm(object aDate,object aScore,DataListCommandEventArgs f)
{
aDate=(((Label)f.Item.FindControl("lblActivityDate")).Text);
aScore= (((Label)f.Item.FindControl("lblActivityScore")).Text);
string scriptblock = "<script
language='javascript'>window.open('ABC.aspx'_blank','width='+700+',height='+610+',top=0,left=0,scrollbars=1,menubar=no,toolbar=no,location=no');</script>";
Page.RegisterStartupScript("OpenPrintWindow", scriptblock);
}
But when I use this method
protected void dgdActivities_ItemCommand(Object s,DataListCommandEventArgs e)
{
if(e.CommandName=="Print")
{
OpenForm(Session["BDate"],Session["BScore"],e);
}
}
the variables Session["BDate"] and Session["BScore"] are empty. Because
when I use Session["BDate"] and Session["BScore"] on some other Web forms
it throws the following error
Object reference not set to an instance of an object
the variables Session["BDate"] and Session["BScore"] are empty.
Any help would be greatly appreciated. Below is my sample HTML code:
<ItemTemplate>
<tr align="center">
<td>
<asp:Label ID="lblActivityName"
Text='<%#DataBinder.Eval(Container.DataItem,"ActivityName")%>' Runat="server">
</asp:Label></td>
<td>
<asp:Label ID="lblActivityDate"
Text='<%#DataBinder.Eval(Container.DataItem,"ActivityDate","{0:d}")%>'
Runat="server">
</asp:Label></td>
<td>
<asp:Label ID="lblActivityScore"
Text='<%#DataBinder.Eval(Container.DataItem,"Score")%>' Runat="server">
</asp:Label></td>
<td>
<asp:Button ID="btnPrintCertificate" Text="Print"
CommandName="Print" Runat="server"></asp:Button></td>
</tr>
</ItemTemplate>
cheers,
Sam Solomon
I am trying to retrieve the value of a DataList cell in a label and assign
it to a Session Variable. For this purpose I am using a method :
private void OpenForm(object aDate,object aScore,DataListCommandEventArgs f)
{
aDate=(((Label)f.Item.FindControl("lblActivityDate")).Text);
aScore= (((Label)f.Item.FindControl("lblActivityScore")).Text);
string scriptblock = "<script
language='javascript'>window.open('ABC.aspx'_blank','width='+700+',height='+610+',top=0,left=0,scrollbars=1,menubar=no,toolbar=no,location=no');</script>";
Page.RegisterStartupScript("OpenPrintWindow", scriptblock);
}
But when I use this method
protected void dgdActivities_ItemCommand(Object s,DataListCommandEventArgs e)
{
if(e.CommandName=="Print")
{
OpenForm(Session["BDate"],Session["BScore"],e);
}
}
the variables Session["BDate"] and Session["BScore"] are empty. Because
when I use Session["BDate"] and Session["BScore"] on some other Web forms
it throws the following error
Object reference not set to an instance of an object
the variables Session["BDate"] and Session["BScore"] are empty.
Any help would be greatly appreciated. Below is my sample HTML code:
<ItemTemplate>
<tr align="center">
<td>
<asp:Label ID="lblActivityName"
Text='<%#DataBinder.Eval(Container.DataItem,"ActivityName")%>' Runat="server">
</asp:Label></td>
<td>
<asp:Label ID="lblActivityDate"
Text='<%#DataBinder.Eval(Container.DataItem,"ActivityDate","{0:d}")%>'
Runat="server">
</asp:Label></td>
<td>
<asp:Label ID="lblActivityScore"
Text='<%#DataBinder.Eval(Container.DataItem,"Score")%>' Runat="server">
</asp:Label></td>
<td>
<asp:Button ID="btnPrintCertificate" Text="Print"
CommandName="Print" Runat="server"></asp:Button></td>
</tr>
</ItemTemplate>
cheers,
Sam Solomon