//翻页 protected void Grid_Standard_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView theGrid = sender as GridView; // refer to the GridView int newPageIndex = 0; if (-2 == e.NewPageIndex) { TextBox txtNewPageIndex = null; GridViewRow pagerRow = Grid_Standard.BottomPagerRow; if (null != pagerRow) { txtNewPageIndex = (TextBox)pagerRow.FindControl("textbox"); // refer to the TextBox with the NewPageIndex value } if (null != txtNewPageIndex && txtNewPageIndex.Text != "") { newPageIndex = int.Parse(txtNewPageIndex.Text) - 1; // get the NewPageIndex } } else { newPageIndex = e.NewPageIndex; } newPageIndex = newPageIndex < 0 ? 0 : newPageIndex; newPageIndex = newPageIndex >= Grid_Standard.PageCount ? Grid_Standard.PageCount - 1 : newPageIndex; Grid_Standard.PageIndex = newPageIndex; Grid_Standard.DataBind(); }
//编辑 protected void Grid_Standard_Editing(object sender, GridViewEditEventArgs e) { Grid_Standard.EditIndex = e.NewEditIndex; Grid_Standard.DataSource = iQCBasicDataL.Search_IQCStandardTable_Grid(id_IQCIT_ID, id_IMISD); Grid_Standard.DataBind(); UpdatePanel_Standard.Update(); }
//更新 protected void Grid_Standard_Updating(object sender, GridViewUpdateEventArgs e) { //string iid = Grid_Standard.DataKeys[e.RowIndex].Value.ToString(); Guid id = new Guid(Grid_Standard.DataKeys[e.RowIndex].Value.ToString());//iqct Guid id1 = new Guid(Label31.Text.ToString()); Guid inid = new Guid(Label32.Text.ToString()); //Guid id = new Guid(); string QCSV_Value = ((TextBox)(Grid_Standard.Rows[e.RowIndex].Cells[3].Controls[0])).Text.Trim().ToString(); string QCSV_Result = ((TextBox)(Grid_Standard.Rows[e.RowIndex].Cells[4].Controls[0])).Text.Trim().ToString(); try { iQCBasicDataL.Insert_IQCStandardValue(id1, QCSV_Value, QCSV_Result, id); } catch (Exception) { ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('录入失败!')", true); return; } Grid_Standard.SelectedIndex = -1; Grid_Standard.EditIndex = -1; Grid_Standard.DataSource = iQCBasicDataL.Search_IQCStandardTable_Grid(id_IQCIT_ID, id_IMISD); Grid_Standard.DataBind(); UpdatePanel_Standard.Update(); }
//取消 protected void Grid_Standard_CancelingEdit(object sender, GridViewCancelEditEventArgs e)//取消编辑 { Grid_Standard.SelectedIndex = -1; Grid_Standard.EditIndex = -1; Grid_Standard.DataSource = iQCBasicDataL.Search_IQCStandardTable_Grid(id_IQCIT_ID, id_IMISD); Grid_Standard.DataBind(); UpdatePanel_Standard.Update(); }
//操作Gridview的命令行 protected void Grid_ETTestItem_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Edit_ItemAmount") { Panel_Standard.Visible = true; id_IQCIT_ID = new Guid(e.CommandArgument.ToString()); Grid_Standard.DataSource = iQCBasicDataL.Search_IQCStandardTable_Grid(id_IQCIT_ID, id_IMISD); Grid_Standard.DataBind(); UpdatePanel_Standard.Update(); } }