ProtectedSub Page_Load(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesMe.Load IfNot IsPostBack Then binddata() EndIf
End Sub
PublicSub binddata() '
End Sub
'編輯中
ProtectedSub GridView1_RowEditing(ByVal sender AsObject, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing GridView1.EditIndex = e.NewEditIndex '當(dāng)前編輯行背景色高亮 GridView1.EditRowStyle.BackColor = Color.FromName("#F7CE90") binddata()
End Sub
'分頁(yè) ProtectedSub GridView1_PageIndexChanging(ByVal sender AsObject, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging GridView1.PageIndex = e.NewPageIndex binddata() '重新綁定GridView數(shù)據(jù)的函數(shù) End Sub
'更新 ProtectedSub GridView1_RowUpdating(ByVal sender AsObject, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating Dim clsB AsNew sqlDLTP.business Dim sqlstr AsString Dim ds AsNew DataSet sqlstr ="select hbdwno from etsshbd where hbdcnm='"&CType(GridView1.Rows(e.RowIndex).FindControl("TextBox1"), TextBox).Text.ToString().Trim() &"'" ds = clsB.queryitems(sqlstr) Dim wno AsString= ds.Tables(0).Rows(0)(0).ToString().Trim()
sqlstr ="update etsdl set okscore1='"& _ CType(GridView1.Rows(e.RowIndex).FindControl("TextBox6"), TextBox).Text.ToString().Trim() &"',okscore2='"& _ CType(GridView1.Rows(e.RowIndex).FindControl("TextBox7"), TextBox).Text.ToString().Trim() &"',okscore='"& _ CType(GridView1.Rows(e.RowIndex).FindControl("TextBox8"), TextBox).Text.ToString().Trim() &"',okreport='"& _ CType(GridView1.Rows(e.RowIndex).FindControl("TextBox9"), TextBox).Text.ToString().Trim() &"',okgrad='"& _ CType(GridView1.Rows(e.RowIndex).FindControl("TextBox10"), TextBox).Text.ToString().Trim() &"',memo='"& _ CType(GridView1.Rows(e.RowIndex).FindControl("TextBox12"), TextBox).Text.ToString().Trim() &"' where trano='"& _ GridView1.DataKeys(e.RowIndex).Value.ToString() &"' and wno='"& wno &"'" clsB.ExeSqlCmd(sqlstr) GridView1.EditIndex =-1 binddata() End Sub
'取消 ProtectedSub GridView1_RowCancelingEdit(ByVal sender AsObject, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GridView1.RowCancelingEdit GridView1.EditIndex =-1 binddata() End Sub
'刪除 ProtectedSub GridView1_RowDeleting(ByVal sender AsObject, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting Dim clsB AsNew sqlDLTP.business Dim sqlstr AsString Dim ds AsNew DataSet sqlstr ="select hbdwno from etsshbd where hbdcnm='"&CType(GridView1.Rows(e.RowIndex).FindControl("Label1"), Label).Text.ToString().Trim() &"'" ds = clsB.queryitems(sqlstr) Dim wno AsString= ds.Tables(0).Rows(0)(0).ToString().Trim()
sqlstr ="delete etsdl where trano="& GridView1.DataKeys(e.RowIndex).Value.ToString().Trim() &"and wno='"& wno &"'" clsB.ExeSqlCmd(sqlstr) binddata() End Sub
'綁定行,特效及鏈接列屬性分配等 ProtectedSub GridView1_RowDataBound(ByVal sender AsObject, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then
'鼠標(biāo)經(jīng)過(guò)時(shí),行背景色變 e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#E6F5FA'") '鼠標(biāo)移出時(shí),行背景色變 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'") ' HyperLink列給鏈接值 CType(e.Row.Cells(1).FindControl("HyperLink1"), HyperLink).NavigateUrl ="javascript:void window.open('trashow.aspx?tno="+CType(e.Row.Cells(1).FindControl("HyperLink1"), HyperLink).Text +"','', 'left='+(window.top.screen.width-454)/2+',top='+(window.top.screen.height-454)/2+',width=625,height=500,scrollbars=yes,resizeable=yes');" '當(dāng)有編輯列時(shí),避免出錯(cuò),要加的RowState判斷 If e.Row.RowState = DataControlRowState.Normal Or e.Row.RowState = DataControlRowState.Alternate Then
IfCType(e.Row.Cells(12).FindControl("Label11"), Label).Text ="1"Then CType(e.Row.Cells(12).FindControl("Label11"), Label).Text ="在職" EndIf EndIf EndIf End Sub