怎么获取到我当前选中的Repeater3中的那一行的值, 比如我要删除的时候,得获取当前行的ID 怎么弄?
解决方案 »
- .net wap开发
- 我机器权限的问题 真是郁闷啊???谢谢大家帮忙看看
- 谢先!问:在Global.asax.cs中,函数Application_BeginRequest()与Application_AuthenticateRequest()有什么区别?都可以通过设置对用
- 關於list組件的邦定問題應用(WAP)
- 怎么把函数绑定到gridview上,gridview绑定roles后怎么样改Item(标题)
- 关于asp.net 打印 整个网页 得问题?
- 如何让自己的网页被搜索引擎搜索到?
- 如何实现页面右侧浮动导航???
- 请问如何编写和运行控制台程序?能否举个例子?
- 關於<div>的一些問題,我以前沒用過不知怎麼用?
- 求一javascript正则或者实现代码
- Vss的使用
在后台 取出CommandArgument 的值,
{
if (e.CommandName == "Del")
{ }
}
{
if (e.CommandName == "Del")
{ }
}
{
if (e.CommandName == "Del")
{ }
}
后台调用Label lableText = (Label)Repeater1.Items[e.Item.ItemIndex].FindControl("lbl_Order_Id");
取值的时候直接取它的Text 就行了。
lableText.Text
把ID传值给lable
再将lable设置为隐藏
你提取这行的ID就好办了啊
<div>
<asp:Repeater ID="Repeater1" runat="server" DataMember="DefaultView"
DataSourceID="SqlDataSource1" onitemcommand="Repeater1_ItemCommand">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text=<%# DataBinder.Eval(Container.DataItem, "ProductID")%>></asp:Label>
<asp:Label ID="Label2" runat="server" Text=<%# DataBinder.Eval(Container.DataItem, "ProductName")%>></asp:Label>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Del" CommandArgument=<%# Eval("ProductID") %> >LinkButton</asp:LinkButton>
<br />
</ItemTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [ProductID], [ProductName] FROM [Products]">
</asp:SqlDataSource>
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</div>
CS:protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "Del")
{
//e.CommandArgument就是ID的值,你可以根据这个删除数据库中的记录
}
}
<ItemTemplate>
<tr bgcolor="#FFFFFF">
<td align="center">
<asp:TextBox ID="txtID" runat="server" Height="16px" Width="12px" Text='<%#DataBinder.Eval(Container.DataItem, "Classid ")%>'
Visible="false"></asp:TextBox>
<asp:TextBox ID="TextBox1" runat="server" Height="16px" Width="60px" Text='<%#DataBinder.Eval(Container.DataItem, "ClassName ")%>'></asp:TextBox>
</td>
<td align="center">
<asp:CheckBoxList ID="CBKLanMu" runat="server" RepeatDirection="Horizontal" onclick="changecolor(this)">
<asp:ListItem Value="HengJia">桁架</asp:ListItem>
<asp:ListItem Value="GongCheng">工程服务</asp:ListItem>
<asp:ListItem Value="XiaoGuoTu">效果图</asp:ListItem>
<asp:ListItem Value="GongChengAnLi">工程案例</asp:ListItem>
<asp:ListItem Value="ZhanLanQiCai">展览器材</asp:ListItem>
</asp:CheckBoxList>
</td>
<td align="center">
<asp:TextBox ID="RtxtPaixu" runat="server" Height="16px" Width="66px" Text='<%#Eval("PaiXu") %>'></asp:TextBox>
</td>
<td align="center">
<asp:TextBox ID="RtxtQXspaixu" runat="server" Height="16px" Width="66px" Text='<%#Eval("QXSpaixu") %>'></asp:TextBox>
</td>
<td align="center">
<asp:TextBox ID="RtxtControlType" runat="server" Height="16px" Width="66px"
Text='<%#stringType(Eval("ControlType")) %>'></asp:TextBox>
</td>
<td align="center">
<asp:Button ID="Button3" runat="server" Text="保存" />
</td>
<td align="center">
<asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="return confirm('是否确认删除!');"
CommandName="del" CommandArgument='<%#Eval("Classid ") %>'>删除</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>下面后台
protected void Repeater3_ItemCommand(object source, RepeaterCommandEventArgs e)
{
断点 if (e.Item.ItemIndex > 0)
{
if (e.CommandName.Equals("del"))
{
string aa = e.CommandArgument.ToString();
}
}
} 没有进断点。。 为什么
点击第一个item。 index是0,不会继续执行了。