ASP.NET的控件未在C#中更新 [英] controls of asp.net are not updated in c#

查看:77
本文介绍了ASP.NET的控件未在C#中更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个应用程序,其中包含文本框下拉列表&链接按钮.单击链接按钮时,重定向到具有文本框&的值的下一页下拉列表.但是控件未在cs文件中更新.
链接按钮代码如下

I write one application which contains text box drop down list & link button.when click on link button redirect to next page with value from text box & drop down list.but controls are not updated in cs file.
link button code is as follows

protected void lnkBtnDisplay_Click(object sender, EventArgs e)
    {
        string strName;
        string strCountry;
        strName =txtName.Text;
        strCountry = ddlName.Text;
        Response.Redirect(''Next.aspx?name='' + strName +''&country=&'' + strCountry);
    }


我从txtName&获取空值ddlName中的默认值.为什么在CS文件中不更新此值?

谢谢


I get empty value from txtName & default value from ddlName.why this values are not updated in cs file?

Thanks

推荐答案

2件事:
1.检查 Viewstate 是否已为页面/控件启用.
2.确保将控件数据填充放入页面 IsPostback 属性中.如果您错过了此操作,则下拉列表将再次绑定到数据,并且您将丢失更改.
2 things:
1. Check Viewstate is enabled for the page/controls.
2. Make sure you put the controls data population in page IsPostback property. If you miss this, dropdown would get binded to data again and you will loose the change.


您好,

使用这个
strCountry = ddlName.SelectedItem.Value;
代替

strCountry = ddlName.Text;
Hi,

Use this
strCountry = ddlName.SelectedItem.Value;
Instead of

strCountry = ddlName.Text;


这篇关于ASP.NET的控件未在C#中更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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