要更新Repeater控件的值? [英] To update the value from RepeatER control?

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

问题描述

使用编辑表单时.假设您在编辑表单中使用了Repeater,并且每行中都有一个文本框.因此,每当用户要编辑表单时,我们都必须将较早的值与Textbox控件绑定.通常,我们使用Eval方法与这些控件进行数据绑定.如果需要更新到数据库,则单击更新"按钮.在按钮"中,单击事件",然后编写更新代码.问题来了...新值未分配..这里只分配了旧值..如何从文本框控件中获取新值..

While working with edit form. Suppose you are using Repeater in your edit form and there is Textbox in each row. So whenever user will go to edit form, we will have to bind older values with our Textbox control. Generally we use Eval method for data binding with these control. If they need to update into database, they click an Update button . In Button click Event I write the code for update. Here is the problem comes...the new values does not assigned..here only older values are assigned..how to get the new value from textbox control..

foreach (RepeaterItem item in Repeater1.Items)
{
      TextBox txtName= (TextBox)item.FindControl("txtName");
      string txtvalue= txtName
}


Here String txtvalue only shows old value only..How to get new value

推荐答案



请检查转发器绑定代码是否在回发事件中.
当您不检查页面回发时就会发生这种情况.

像这样使用

if(!ispostback)
{
bindreapter();
}


Please check the repeater binding code is in the postback event.
It happens when you did not check the page postback.

use like this

if(!ispostback)
{
bindreapter();
}


这篇关于要更新Repeater控件的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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