aspx文件中加
<script language="javascript">
<!--
//checkbox全选and反全选
function select_deselectall (chkval, idval)
{
var frm = document.forms[0];
for (i=0; i<frm.length; i++)
{
if (idval.indexof ('checkall') != -1)
{
if(chkval == true)
{
frm.elements[i].checked = true;
}
else
{
frm.elements[i].checked = false;
}
}
else if (idval.indexof('deletethis') != -1)
{
if(frm.elements[i].checked == false)
{
frm.elements[1].checked = false;
}
}
}
}
//-->
</script>
全选<input id="checkall" tabindex="0" type="checkbox" title="点击全选或反全选当前页所有信息">
datagrid中加模板列
<asp:templatecolumn headertext="选定">
<headerstyle width="10%"></headerstyle>
<itemtemplate>
<asp:checkbox id="chkselectbox" runat="server"></asp:checkbox>
</itemtemplate>
</asp:templatecolumn>
cs文件中操作选定项
foreach (datagriditem item in datagrid.items)
{
if(((checkbox)item.findcontrol("chkselectbox")).checked==true)
{
response.write (item.cells[0].text);
}
}
新闻热点
疑难解答