Click here to Skip to main content
15,118,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

I have 2 webpages Pages A,B.

In Page A,I got a linkbutton which redirects to pageB.

I will fill a textbox in page B and clicks submit button.,then again it should redirect to PageA with text(text entered in textbox and placed in session from pageB) and should display in dynamic label of page A (label is available in panel of PageA).

this process is cyclic and each time i enter a text from page B,it should create a new label in page A,without removing old label.


My Issue is when I write a new text in page B,its removing old comment and replacing with a new one.and that too label availabe is a static one(I dragged from toolbox).

So I got a solution for this (ie)to place datalist,below is the code for it:

XML
PageB:

save comments click event:

lDialogcomment.Text=textbox1.text;

Session["Output"] = lDialogcomment.Text + "                                          " + lsUserName.Text + "                                        " + time;

List<string> values = new List<string>();

if (Session["Output"] != null)

values = Session["Output"] as List<string>;

Response.Redirect("Page A.aspx");



PAGE A:

public void BindData()

{

dlValues.DataSource = Output;

dlValues.DataBind();

 }



public List<string> Output

    {

     get

{

    List<string> values = new List<string>();

           if (Session["Output"] == null)

{

Session["Output"] = new List<string>();

            }

          return Session["Output"] as List<string>;

        }

       set

        {

            Session[

"Output"] = value;

        }

    }


Page-load event:

(!ispostbacK)

BindData();



Datalist Control Design Source

<asp:DataList ID="dlValues" runat="server" RepeatDirection="Vertical">

<ItemTemplate>

asp:Label Text="<%# Container.DataItem %>" ID="lblValue" runat="server"></asp:Label>

</ItemTemplate>

</asp:DataList>



no build errors,no runtime errors and also no desired output.


Please help me in this ASAP,as it it very critical situation for me.
Posted
Comments
[no name] 26-Mar-14 19:56pm
   
"lDialogcomment.Text=textbox1.text;", it's replacing the comment text because that is exactly what you are telling it to do.

1 solution

The best way is make temp table in database and each time save and fetch data from there because in session save large amount of value will take more load on server.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900