Panel中的动态标签创建 [英] Dynamic label creation in Panel

查看:97
本文介绍了Panel中的动态标签创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我有2个网页A,B页。



页A ,我有一个链接按钮,重定向到pageB。



我将在页面B填写一个文本框并单击提交按钮。然后它应该再次使用文本重定向到PageA(文本在文本框中输入并放在会话中从pageB)并且应该显示在页面A的动态标签中(标签在PageA面板中可用)。



此过程是循环的,每次我从页面B输入文本,它应该在页面A中创建一个新标签,而不删除旧标签。





我的问题是当我写一个新文本时第B页,删除旧评论并替换为新评论。标签可用性也是静态的(我从工具箱中拖出)。



所以我得到了一个解决方案(即)放置datalist,下面是代码:



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:

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.

推荐答案

最好的办法是在数据库中创建临时表,每次从那里保存和获取数据,因为在会话中保存大量的值将在服务器上承担更多的负载。
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.


这篇关于Panel中的动态标签创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆