|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DataList IssueI 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 Where are you adding the variables to the Session. I don't see it in the
supplied code. Sam Solomon wrote: Show quoteHide quote >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 -- Seth Webster Message posted via DotNetMonster.com http://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net-web-controls/200511/1
Cool Web Parts?
Newbie - question concerning page behaviour One comment about the implementation of Session FormView DateTime bug?? Problems with Custom Web Controls in VS 2005 Time textbox control Strange temporary error after applying .Net SP1 TableAdapter Scalar or "Single Value" Queries regular expression Mailto Link in Gridview |
|||||||||||||||||||||||