html代码如下:
<asp:Repeater ID="OrderList" runat="server" onitemcommand="OrderList_ItemCommand" onitemdatabound="OrderList_ItemDataBound">
<HeaderTemplate>
<tr>
<th width="30"><asp:CheckBox ID="cBox1" runat="server" /></th>
<th width="30"><asp:LinkButton ID="LinkButton1" runat="server" CommandName="action">序号</asp:LinkButton></th>
<th width="160"><asp:LinkButton ID="olist" runat="server" CommandName="olist">送货单号</asp:LinkButton></th>
<th width="80"><asp:LinkButton ID="sname" runat="server" CommandName="sname">供应商</asp:LinkButton></th>
<th width="80"><asp:LinkButton ID="snameid" runat="server" CommandName="snameid">供应商ID</asp:LinkButton></th>
<th width="100"><asp:LinkButton ID="sdate" runat="server" CommandName="sdate">交货日期</asp:LinkButton></th>
<th width="100"><asp:LinkButton ID="stime" runat="server" CommandName="stime">交货时间</asp:LinkButton></th>
<th width="120"><asp:LinkButton ID="pkind" runat="server" CommandName="pkind">付款方式</asp:LinkButton></th>
<th width="100"><asp:LinkButton ID="ptime" runat="server" CommandName="ptime">报价时间</asp:LinkButton></th>
<th width="100"><asp:LinkButton ID="gdtime" runat="server" CommandName="gdtime">发货时间</asp:LinkButton></th>
<th width="100"><asp:LinkButton ID="grtime" runat="server" CommandName="grtime">收货时间</asp:LinkButton></th>
<th width="160"><asp:LinkButton ID="re" runat="server" CommandName="re">备注</asp:LinkButton></th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:CheckBox ID="cBox" runat="server" /></td>
<td><asp:Literal ID="oReqn" runat="server" Text='<%#Eval("OReqn")%>'></asp:Literal></td>
<td><asp:Literal ID="oList" runat="server" Text='<%#Eval("OList")%>'></asp:Literal></td>
<td><asp:Literal ID="sName" runat="server" Text='<%#Eval("SName")%>'></asp:Literal></td>
<td><asp:Literal ID="sNameid" runat="server" Text='<%#Eval("SId")%>'></asp:Literal></td>
<td><asp:Literal ID="sDate" runat="server" Text='<%#Eval("SDate")%>'></asp:Literal></td>
<td><asp:Literal ID="sTime" runat="server" Text='<%#Eval("STime")%>'></asp:Literal></td>
<td><asp:Literal ID="pKind" runat="server" Text='<%# TransPKind(Eval("PKind").ToString())%>'></asp:Literal></td>
<td><asp:Literal ID="pTime" runat="server" Text='<%#Eval("PTime")%>'></asp:Literal></td>
<td><asp:Literal ID="gDTime" runat="server" Text='<%#Eval("GDTime")%>'></asp:Literal></td>
<td><asp:Literal ID="gRTime" runat="server" Text='<%#Eval("GRTime")%>'></asp:Literal></td>
<td><asp:Literal ID="oRe" runat="server" Text='<%#Eval("ORe")%>'></asp:Literal></td>
</tr>
</ItemTemplate>
</asp:Repeater>实现点击repeater头部(HeaderTemplate)的checkbox,全选ItemTemplate中的checkbox,再次单击时取消全选。本人新手,望帮助!谢谢!
<asp:Repeater ID="OrderList" runat="server" onitemcommand="OrderList_ItemCommand" onitemdatabound="OrderList_ItemDataBound">
<HeaderTemplate>
<tr>
<th width="30"><asp:CheckBox ID="cBox1" runat="server" /></th>
<th width="30"><asp:LinkButton ID="LinkButton1" runat="server" CommandName="action">序号</asp:LinkButton></th>
<th width="160"><asp:LinkButton ID="olist" runat="server" CommandName="olist">送货单号</asp:LinkButton></th>
<th width="80"><asp:LinkButton ID="sname" runat="server" CommandName="sname">供应商</asp:LinkButton></th>
<th width="80"><asp:LinkButton ID="snameid" runat="server" CommandName="snameid">供应商ID</asp:LinkButton></th>
<th width="100"><asp:LinkButton ID="sdate" runat="server" CommandName="sdate">交货日期</asp:LinkButton></th>
<th width="100"><asp:LinkButton ID="stime" runat="server" CommandName="stime">交货时间</asp:LinkButton></th>
<th width="120"><asp:LinkButton ID="pkind" runat="server" CommandName="pkind">付款方式</asp:LinkButton></th>
<th width="100"><asp:LinkButton ID="ptime" runat="server" CommandName="ptime">报价时间</asp:LinkButton></th>
<th width="100"><asp:LinkButton ID="gdtime" runat="server" CommandName="gdtime">发货时间</asp:LinkButton></th>
<th width="100"><asp:LinkButton ID="grtime" runat="server" CommandName="grtime">收货时间</asp:LinkButton></th>
<th width="160"><asp:LinkButton ID="re" runat="server" CommandName="re">备注</asp:LinkButton></th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:CheckBox ID="cBox" runat="server" /></td>
<td><asp:Literal ID="oReqn" runat="server" Text='<%#Eval("OReqn")%>'></asp:Literal></td>
<td><asp:Literal ID="oList" runat="server" Text='<%#Eval("OList")%>'></asp:Literal></td>
<td><asp:Literal ID="sName" runat="server" Text='<%#Eval("SName")%>'></asp:Literal></td>
<td><asp:Literal ID="sNameid" runat="server" Text='<%#Eval("SId")%>'></asp:Literal></td>
<td><asp:Literal ID="sDate" runat="server" Text='<%#Eval("SDate")%>'></asp:Literal></td>
<td><asp:Literal ID="sTime" runat="server" Text='<%#Eval("STime")%>'></asp:Literal></td>
<td><asp:Literal ID="pKind" runat="server" Text='<%# TransPKind(Eval("PKind").ToString())%>'></asp:Literal></td>
<td><asp:Literal ID="pTime" runat="server" Text='<%#Eval("PTime")%>'></asp:Literal></td>
<td><asp:Literal ID="gDTime" runat="server" Text='<%#Eval("GDTime")%>'></asp:Literal></td>
<td><asp:Literal ID="gRTime" runat="server" Text='<%#Eval("GRTime")%>'></asp:Literal></td>
<td><asp:Literal ID="oRe" runat="server" Text='<%#Eval("ORe")%>'></asp:Literal></td>
</tr>
</ItemTemplate>
</asp:Repeater>实现点击repeater头部(HeaderTemplate)的checkbox,全选ItemTemplate中的checkbox,再次单击时取消全选。本人新手,望帮助!谢谢!
解决方案 »
- kindEditor 在线编辑器 谁会用的 进来看看!!!
- 关于ASP.NET MVC中的用户管理
- 文本标引思路,求各位指导,尽管给思路
- 关于ASP。NET中欠入FrameSet后整个页面的大小问题
- 您随便入侵,成功了您说话!
- jquery验证用户名是否存在的问题
- 各位可知,Google的左侧排名是如何实现的?
- MVC 强类型传值,如何隐藏一些关键的禁止修改属性?
- 在ASP.NET中怎样实现将client上的电子表格数据送到server上的sql server数据库里
- 关于WebControl的事件
- new { controller = new NotEqual("Admin")} 报错
- c#页面程序中,向SQL SERVER 2008 插入记录总是产生Exception消息
{
if(bool)
{
删除
}
}
oncheckedchanged="CheckBox2_CheckedChanged1" AutoPostBack="True"
/><asp:Button ID="Button1" runat="server" Text="获取值"
onclick="Button1_Click" />
<asp:Repeater ID="Repeater1" runat="server" onitemcommand="Repeater1_ItemCommand"
>
<ItemTemplate>
<asp:Button ID="Button2" runat="server" Text="Button" CommandName="but" CommandArgument='<%# Eval("sname") %>' Visible="false" />
<div style="width:150px;">
<div id="ck" style="width:30px; height:auto; border:1px solid black; float:left;">
<asp:CheckBox ID="cb1" runat="server" />
</div>
<div id="sj" style="width:110px; height:auto; border:1px solid black; float:left;">
<%# Eval("sname") %>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
后台 protected void CheckBox2_CheckedChanged1(object sender, EventArgs e)
{
if (CheckBox2.Checked == true)
{
for (int i = 0; i < Repeater1.Items.Count; i++)
{
((CheckBox)Repeater1.Items[i].FindControl("cb1")).Enabled = false;
((CheckBox)Repeater1.Items[i].FindControl("cb1")).Checked = true;
}
}
else if (CheckBox2.Checked == false)
{
for (int i = 0; i < Repeater1.Items.Count; i++)
{
((CheckBox)Repeater1.Items[i].FindControl("cb1")).Enabled = true;
((CheckBox)Repeater1.Items[i].FindControl("cb1")).Checked = false;
}
}
} protected void Button1_Click(object sender, EventArgs e)
{
if (CheckBox2.Checked == false)
{
for (int i = 0; i < Repeater1.Items.Count; i++)
{
if (((CheckBox)Repeater1.Items[i].FindControl("cb1")).Checked == true)
{ Response.Write(((Button)Repeater1.Items[i].FindControl("Button2")).CommandArgument.ToString()); }
} }
else
{
for (int i = 0; i < Repeater1.Items.Count; i++)
{ Response.Write( ((Button)Repeater1.Items[i].FindControl("Button2")).CommandArgument.ToString()); }
}
}
/// <summary>
/// 批量删除
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
for (int i = 0; i < Repeater1.Items.Count; i++)
{
CheckBox Cb = (CheckBox)Repeater1.Items[i].FindControl("CheckBoxID");
//ID
if (Cb.Checked)
{
//删除
}
}
}
<script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$(".chx").each(function (i, j) {
$(j).click(function () {
if ($(this).attr("checked"))
$(this).find("input[type='text']").attr("disabled", "disabled");
else
$(this).find("input[type='text']").attr("disabled", "");
});
});
$("[name=chx_all]").click(function () {
var chx = $(this).attr("checked");
$("[name=chx_select]").each(function (i, j) {
if (chx)
$(j).attr("checked", "checked");
else
$(j).attr("checked", "");
});
});
});
</script><table>
<tr>
<td>
<input type="checkbox" name="chx_all" value="0" />
</td>
<td>姓名</td>
</tr>
<tr>
<td>
<input type="checkbox" name="chx_select" class="chx" value="1" />
</td>
<td>
<input type="text" />
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="chx_select" class="chx" value="2" />
</td>
<td>
<input type="text" />
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="chx_select" class="chx" value="3" />
</td>
<td>
<input type="text" />
</td>
</tr>
</table>可以试试我的代码
$(".chx").each(function (i, j) {
$(j).click(function () {
if ($(this).attr("checked"))
$(this).find("input[type='text']").attr("disabled", "disabled");
else
$(this).find("input[type='text']").attr("disabled", "");
});
});
这个是别的功能的,有错误,可以删除掉
function checkAll(obj) {
var tt = document.getElementsByTagName("input");
for (var i = 0; i < tt.length; i++) {
if (tt[i].type == "checkbox") {
if (obj.checked == true) {
tt[i].checked = true;
}
if (obj.checked == false) {
tt[i].checked = false;
}
}
}
}
<input name="checkbox3" type="checkbox" class="fxk" value="checkbox" onclick="checkAll(this)" />