我程序中有一个repeater控件,绑定了数据源的,我如何在后台.cs文件中获取到repeater中绑定的数据?请赐教 10
<asp:RepeaterID="Repeater1"runat="server"><ItemTemplate><divstyle="border-style:solid...
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<div style="border-style: solid; width: 600px; height: 110px; margin-left:50px; margin-top: 20px; background-color: #008080;">
<div style=" width:80px; height: 80px; position: absolute;"><img alt="" src="头像/5001.jpg" width="80" height="80" /></div>
<div style=" width: 520px; height: 20px; margin-left:90px; position: absolute; "><%# DataBinder .Eval (Container .DataItem ,"time") %> 留言</div>
<div style=" width: 60px; height: 40px; margin-left:10px; margin-top: 85px; position: absolute;"><%# DataBinder .Eval (Container .DataItem ,"username") %></div>
<div style=" width: 510px; height: 110px; margin-left:45px; margin-top: 20px; position: absolute; ">
<asp:TextBox ID="TextBox2" runat="server" Text='<%# DataBinder .Eval (Container .DataItem ,"message_content") %>' Width="400" Height="40"></asp:TextBox>
</div>
<div style=" width: 510px; height: 110px; margin-left:220px; margin-top: 70px; position: absolute; ">
<asp:Button ID="Delete" runat="server" Text="删 除" OnClientClick ="return confirm('确认要删除吗?');" OnClick ="shiyan" />
</div>
<asp:Label ID="Label7" runat="server" Text='<%# DataBinder .Eval (Container .DataItem ,"message_id") %>' Visible="False"></asp:Label>
</div>
</ItemTemplate>
<FooterTemplate >
<span style="margin-left: 460px">
<div>
</div>
</span>
</FooterTemplate>
</asp:Repeater>
我想在后台获取repeater中绑定的ID值,如:<%# DataBinder .Eval (Container .DataItem ,"message_id") %>,怎么获取得到, <asp:Button ID="Delete" runat="server" Text="删 除" OnClientClick ="return confirm('确认要删除吗?');" OnClick ="shiyan" />怎样从这个Button中把参数传出去呢?
各位高手还有何种解法?望赐教,本人初学者,不懂 展开
<ItemTemplate>
<div style="border-style: solid; width: 600px; height: 110px; margin-left:50px; margin-top: 20px; background-color: #008080;">
<div style=" width:80px; height: 80px; position: absolute;"><img alt="" src="头像/5001.jpg" width="80" height="80" /></div>
<div style=" width: 520px; height: 20px; margin-left:90px; position: absolute; "><%# DataBinder .Eval (Container .DataItem ,"time") %> 留言</div>
<div style=" width: 60px; height: 40px; margin-left:10px; margin-top: 85px; position: absolute;"><%# DataBinder .Eval (Container .DataItem ,"username") %></div>
<div style=" width: 510px; height: 110px; margin-left:45px; margin-top: 20px; position: absolute; ">
<asp:TextBox ID="TextBox2" runat="server" Text='<%# DataBinder .Eval (Container .DataItem ,"message_content") %>' Width="400" Height="40"></asp:TextBox>
</div>
<div style=" width: 510px; height: 110px; margin-left:220px; margin-top: 70px; position: absolute; ">
<asp:Button ID="Delete" runat="server" Text="删 除" OnClientClick ="return confirm('确认要删除吗?');" OnClick ="shiyan" />
</div>
<asp:Label ID="Label7" runat="server" Text='<%# DataBinder .Eval (Container .DataItem ,"message_id") %>' Visible="False"></asp:Label>
</div>
</ItemTemplate>
<FooterTemplate >
<span style="margin-left: 460px">
<div>
</div>
</span>
</FooterTemplate>
</asp:Repeater>
我想在后台获取repeater中绑定的ID值,如:<%# DataBinder .Eval (Container .DataItem ,"message_id") %>,怎么获取得到, <asp:Button ID="Delete" runat="server" Text="删 除" OnClientClick ="return confirm('确认要删除吗?');" OnClick ="shiyan" />怎样从这个Button中把参数传出去呢?
各位高手还有何种解法?望赐教,本人初学者,不懂 展开
2个回答
展开全部
button有个属性CommandArgument,你可以给它赋值,然后后台的shiyan事件中,string zhi = (sender as Button).CommandArgument; zhi就是你要的值了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询