- using System;
- 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;
- public partial class Works_item_Conversion : System.Web.UI.Page
- {
- SqlTextService.SqlTextService ts = new SqlTextService.SqlTextService();
- //DataSet ds;
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- this.DataGridDataBind();
- }
- //进行数据绑定
- private void DataGridDataBind()
- {
- try
- {
- //进行数据绑定
- this.GridView1.DataSource = ts.GetItemDeclareForm();
- this.GridView1.DataBind();
- LblCurrentIndex.Text = "第 " + (GridView1.PageIndex + 1).ToString() + " 页/";
- LblPageCount.Text = "共 " + GridView1.PageCount.ToString() + " 页/";
- LblRecordCount.Text = "总共 " + ts.GetItemDeclareForm().Tables[0].Rows.Count.ToString() + " 条";
- if (ts.GetItemDeclareForm().Tables[0].Rows.Count == 0)
- {
- btnFirst.Visible = false;
- btnPrev.Visible = false;
- btnNext.Visible = false;
- btnLast.Visible = false;
- LblCurrentIndex.Visible = false;
- LblPageCount.Visible = false;
- LblRecordCount.Visible = false;
- }
- else if (GridView1.PageCount == 1)
- {
- btnFirst.Visible = false;
- btnPrev.Visible = false;
- btnNext.Visible = false;
- btnLast.Visible = false;
- }
- // 计算生成分页页码,分别为:"首 页" "上一页" "下一页" "尾 页"
- btnFirst.CommandName = "1";
- btnPrev.CommandName = (GridView1.PageIndex == 0 ? "1" : GridView1.PageIndex.ToString());
- btnNext.CommandName = (GridView1.PageCount == 1 ? GridView1.PageCount.ToString() : (GridView1.PageIndex + 2).ToString());
- btnLast.CommandName = GridView1.PageCount.ToString();
- }
- catch (Exception error)
- {
- //输出异常信息
- Response.Write(error.ToString());
- Response.End();
- }
- }
- protected void PagerButtonClick(object sender, EventArgs e)
- {
- GridView1.PageIndex = Convert.ToInt32(((LinkButton)sender).CommandName) - 1;
- DataGridDataBind();
- }
- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- e.Row.Attributes["onmouseover"] = "ItemOver(this)";
- }
- protected void LinkButton1_Click1(object sender, EventArgs e)
- {
- int DelId = 0;
- for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
- {
- HtmlInputCheckBox chk = (HtmlInputCheckBox)GridView1.Rows[i].FindControl("chkExport");
- if (chk.Checked==true)
- {
- DelId=ts.UpdateItemDeclareForm(GridView1.DataKeys[i].Value.ToString ());
- }
- }
- this.DataGridDataBind();
- //foreach (GridViewRow i in GridView1.Rows)
- //{
- chk =(HtmlInputCheckBox)i.FindControl("chkExport");
- lb = (Label)i.FindControl("Lb_id");
- // CheckBox cbox = (CheckBox)i.FindControl("chkExport");
- // //如果选中了则取值
- // if (chk.Checked )
- // {
- // DelId = lb.Text;
- // //ts.UpdateItemDeclareForm(DelId);
- // //formid += this.GridView1.DataKeys[i.RowIndex].Value.ToString() + ",";
- // }
- //}
- }
- }
html中的checkbox如何在GridView选中并取值(c#)
最新推荐文章于 2024-08-07 14:19:47 发布