获取Repeater中 批改后的textbox 绑定值
获取Repeater中 修改后的textbox 绑定值 asp:Repeater IDDevelopmentTarget runatserverHeaderTe
获取Repeater中 修改后的textbox 绑定值
<asp:Repeater ID="DevelopmentTarget" runat="server">
<HeaderTemplate>
<table>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text=' <%#Eval( "id")%> ' Visible="false"></asp:Label>
</td>
<td><%# ((DataRowView )Container.DataItem)["Name"] %>:
<asp:TextBox ID="TextBox1" Class="EditWeight" Text='<%# ((DataRowView )Container.DataItem)["Weight"] %>' runat="server" ReadOnly="True"></asp:TextBox>%(单位百分比)</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>
上面是通过repeater控件动态绑定数据库中的值,然后绑定到textbox中,但是当我编辑在textbox中输入新值后,后台获取的还是原先的值
后台
protected void cmdCity_Click(object sender, EventArgs e)
{
EvaluationSystem.Model.CharacterizationTargetWeightEntity characterizationTargetWeightEntity = new CharacterizationTargetWeightEntity();
EvaluationSystem.BLL.CharacterizationTargetWeightBLL characterizationTargetWeightBll = new CharacterizationTargetWeightBLL();
foreach (RepeaterItem ri in CityTarget.Items)
{
//获取修改后的权重
TextBox txtWeight = (TextBox)ri.FindControl("TextBox1");
string Weight = txtWeight.Text;
Label labelid = (Label)ri.FindControl("Label1");
string TargetID = labelid.Text;
characterizationTargetWeightEntity.Id = TargetID;
characterizationTargetWeightEntity.Weight = Weight;
//if (characterizationTargetWeightBll.Update(characterizationTargetWeightEntity) == true)
//{
// //更新成功
//}
//else {
//更新失败
}
}
[解决办法]
你的更新不是注释掉了?
[解决办法]
string Weight = Request.Form[txtWeight.UniqueID] //这个应该能取到值
[解决办法]
一般来说不会啊 你弄更新的话应该是点击提交按钮 这个时候页面不刷新不回访的话值应该是你修改后的值 你点击提交 修改了数据库后刷新这个时候绑定的应该是 修改后的值了啊