<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="id" ForeColor="#333333"
GridLines="None" Style="z-index: 100; left: 163px; position: absolute;
top: 104px" Width="729px" CssClass="adminlist" EnableViewState="False" EmptyDataText="没有你所查找的记录" AllowSorting="True" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" PageSize="20">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server"/>
</ItemTemplate>
<HeaderTemplate>
<input id="chkAll" onclick="SelectAllCheckboxes(this);" runat="server" type="checkbox" />
</HeaderTemplate>
<ItemStyle HorizontalAlign="Left" Width="25px" />
</asp:TemplateField>
<asp:BoundField DataField="btsrxm" HeaderText="被投诉人姓名" SortExpression="btsrxm" >
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="cddm" HeaderText="车队" SortExpression="cddm" >
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="tsxz" HeaderText="投诉性质" SortExpression="tsxz" >
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="tsnr" HeaderText="投诉内容" SortExpression="tsnr" >
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="tsrq" HeaderText="投诉日期" SortExpression="tsrq" >
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="jbr" HeaderText="经办人" SortExpression="jbr" >
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<input ID="id" name='<%# Eval("ID") %>' type=hidden Value='<%# Eval("ID") %>' />
<a href="addfuwu.aspx?action=edit&id=<%# Eval("ID") %>" id="a2" >修改</a>
<a href="addfuwu.aspx?action=view&id=<%# Eval("ID") %>" id="a1" >查看</a>
<asp:Button ID="Button1" runat="server" CausesValidation="False" CommandName="Delete"
Text="删除" OnClientClick="return confirm('您确认删除该记录吗?');" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>没有你所查找的记录</EmptyDataTemplate>
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" BorderStyle="Groove" />
<EmptyDataRowStyle VerticalAlign="Top" />
<PagerTemplate>
</PagerTemplate>
</asp:GridView>
</div>
<div style="text-align:left">
<br />
</div>
<table border="1" cellpadding="0" cellspacing="0" bordercolorlight="#FFFFFF" bordercolordark="#E6E6E6" bgcolor="#FFFFFF" style="left: 190px; width: 73%; position: relative; top: -6px; height: 24px">
<tr><td style="height: 24px; width: 200px;">
<asp:Button ID="Button2" runat="server" Text="批量删除用户" CommandName="Delete" OnClientClick="return confirm('您确认删除该记录吗?');" OnClick="Button2_Click"/>
</td>
<td align=right style="height: 24px; width: 325px;">
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" Style="position: relative" OnPageChanged="AspNetPager1_PageChanged" PageSize="20" Width="310px" FirstPageText="首页 " LastPageText=" 末页" NextPageText="下一页" PrevPageText="上一页">
</webdiyer:AspNetPager>
</td>
</tr></table>
<asp:Label ID="Label1" runat="server" Height="20px" Style="left: 47px; position: relative;
top: 58px" Text="Label" Width="87px"></asp:Label>
</form>
<div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="id" ForeColor="#333333"
GridLines="None" Style="z-index: 100; left: 163px; position: absolute;
top: 104px" Width="729px" CssClass="adminlist" EnableViewState="False" EmptyDataText="没有你所查找的记录" AllowSorting="True" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" PageSize="20">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server"/>
</ItemTemplate>
<HeaderTemplate>
<input id="chkAll" onclick="SelectAllCheckboxes(this);" runat="server" type="checkbox" />
</HeaderTemplate>
<ItemStyle HorizontalAlign="Left" Width="25px" />
</asp:TemplateField>
<asp:BoundField DataField="btsrxm" HeaderText="被投诉人姓名" SortExpression="btsrxm" >
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="cddm" HeaderText="车队" SortExpression="cddm" >
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="tsxz" HeaderText="投诉性质" SortExpression="tsxz" >
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="tsnr" HeaderText="投诉内容" SortExpression="tsnr" >
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="tsrq" HeaderText="投诉日期" SortExpression="tsrq" >
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="jbr" HeaderText="经办人" SortExpression="jbr" >
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<input ID="id" name='<%# Eval("ID") %>' type=hidden Value='<%# Eval("ID") %>' />
<a href="addfuwu.aspx?action=edit&id=<%# Eval("ID") %>" id="a2" >修改</a>
<a href="addfuwu.aspx?action=view&id=<%# Eval("ID") %>" id="a1" >查看</a>
<asp:Button ID="Button1" runat="server" CausesValidation="False" CommandName="Delete"
Text="删除" OnClientClick="return confirm('您确认删除该记录吗?');" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>没有你所查找的记录</EmptyDataTemplate>
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" BorderStyle="Groove" />
<EmptyDataRowStyle VerticalAlign="Top" />
<PagerTemplate>
</PagerTemplate>
</asp:GridView>
</div>
<div style="text-align:left">
<br />
</div>
<table border="1" cellpadding="0" cellspacing="0" bordercolorlight="#FFFFFF" bordercolordark="#E6E6E6" bgcolor="#FFFFFF" style="left: 190px; width: 73%; position: relative; top: -6px; height: 24px">
<tr><td style="height: 24px; width: 200px;">
<asp:Button ID="Button2" runat="server" Text="批量删除用户" CommandName="Delete" OnClientClick="return confirm('您确认删除该记录吗?');" OnClick="Button2_Click"/>
</td>
<td align=right style="height: 24px; width: 325px;">
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" Style="position: relative" OnPageChanged="AspNetPager1_PageChanged" PageSize="20" Width="310px" FirstPageText="首页 " LastPageText=" 末页" NextPageText="下一页" PrevPageText="上一页">
</webdiyer:AspNetPager>
</td>
</tr></table>
<asp:Label ID="Label1" runat="server" Height="20px" Style="left: 47px; position: relative;
top: 58px" Text="Label" Width="87px"></asp:Label>
</form>
解决方案 »
- 请问javascript中 >>> 这个符号 相当于 asp.net 中为什么符号
- 各位大哥大姐帮帮我
- asp.net多文件上传中 怎么从HttpFileCollection集合中分离出 具有相同key的文件
- 怎样把一个treeview的递归改成checkBoxlist的递归
- gridview1控件绑定出错,怎么修改?
- 这是什么 在vbs中
- Visual Studio 2005里为什么没有DataGrid控件呢?
- 自定义控件高手请进^_^
- help!如何实现选择左边菜单,然后右边显示内容
- asp.net 数据链接的问题--解决问题另送100分
- 关于自定义控件的输出机制,高分求教
- 两个c# asp.net编程的奇怪的问题,请有经验的帮助
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Wuqi.Webdiyer;
public partial class fuwutousu : System.Web.UI.Page
{
static string connStr = ConfigurationManager.ConnectionStrings["con"].ToString();
SqlConnection conn = new SqlConnection(connStr);
public void databinds()
{
} //public void CutPageData(SqlConnection conn,ref SqlCommand comm, string _tblName, string _fldName, int _pageSize, int _page, string _fldSort, int _Sort, string _ID, ref SqlDataReader _dr)
//{
// //注意:在函数调用外部打开和关闭连接,以及关闭数据读取器
// //conn.Open();
// //SqlCommand comm = new SqlCommand("ListPageInt", conn);
// //comm.CommandType = CommandType.StoredProcedure;
// comm.Parameters.Add("@tblName", SqlDbType.NVarChar, 200);
// comm.Parameters["@tblName"].Value = _tblName;
// comm.Parameters.Add("@fldName", SqlDbType.NVarChar, 500);
// comm.Parameters["@fldName"].Value = _fldName;
// comm.Parameters.Add("@pageSize", SqlDbType.Int);
// comm.Parameters["@pageSize"].Value = _pageSize;
// comm.Parameters.Add("@page", SqlDbType.Int);
// comm.Parameters["@page"].Value = _page;
// comm.Parameters.Add("@fldSort", SqlDbType.NVarChar, 200);
// comm.Parameters["@fldSort"].Value = _fldSort;
// comm.Parameters.Add("@Sort", SqlDbType.Bit);
// comm.Parameters["@Sort"].Value = _Sort;
// //comm.Parameters.Add("@strCondition", SqlDbType.NVarChar, 1000);
// //comm.Parameters["@strCondition"].Value = _strCondition;
// comm.Parameters.Add("@ID", SqlDbType.NVarChar, 150);
// comm.Parameters["@ID"].Value = _ID;
// comm.Parameters.Add("@Counts", SqlDbType.Int, 0);
// comm.Parameters["@Counts"].Direction = ParameterDirection.Output;
// comm.Parameters.Add("@pageCount", SqlDbType.Int, 0);
// comm.Parameters["@pageCount"].Direction = ParameterDirection.Output;
// _dr = comm.ExecuteReader();
// //GridView1.DataSource = _dr;
// //GridView1.DataBind();
// //conn.Close();
//} protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
string sql = "select count(*) from [T_GJJT_BZ_1_AQDZ_1]";
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
AspNetPager1.RecordCount = (int)cmd.ExecuteScalar();
conn.Close();
binddata();
}
}
public void binddata()
{
string sql = "select * from [T_GJJT_BZ_1_AQDZ_1]"; SqlDataAdapter da = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
da.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "userinfo");
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void Button2_Click(object sender, EventArgs e)
{
conn.Open();
//for (int rowindex = this.GridView1.Rows.Count - 1; rowindex >= 0; rowindex--)
for (int rowindex = 0; rowindex < this.GridView1.Rows.Count;rowindex++ )
{
if (((CheckBox)this.GridView1.Rows[rowindex].Cells[0].FindControl("chkSelect")).Checked == true)
{
int i = Convert.ToInt32(this.GridView1.DataKeys[rowindex].Value);
string sql = "delete from [T_GJJT_BZ_1_AQDZ_1] where id=" + i.ToString();
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.ExecuteNonQuery(); }
}
conn.Close();
binddata();
}
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
binddata();
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{ }
}
单步调试说GridView1.Rows.Count 为0,结果没进入for循环,就没执行删除语句。
高手帮忙解决下吧~~