Public class mymanage inherits system.web.ui.page
#Region "The code" of the web form designer "
'This call is required for the web form designer.
End sub protected withevents data data as system.Web.ui.WebControls.DataGrid protected withevents form1 as system.web.ui.htmlControls.htmlform
'Note: The following placeholders declare are required by the web form designer. 'Don't delete or move it. Private DesignerPlaceHolderDeclaration as System.Object
Private Sub Page_init (Byval E AS System.EventArgs) Handles mybase.init 'Codegen: This method call is required by the Web Form Designer' Do not modify it using the code editor. InitializationComponent () End Sub
#End region
Private Sub Page_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then bindgrid () End If End Sub Sub bindgrid () 'DataGrid1.DataSource = mydb.gettable ( "select * from articles where art_col_sub = "& Request.QueryString (" art_col_sub ")) DataGrid1.DataSource = mydb.gettable (CType (Request.QueryString (" art_col_sub "), Integer)) DataGrid1.DataKeyField =" id "DataGrid1.DataBind ( ) End Sub Private Sub DataGrid1_Selected Indexchanged (Byval E AS System.EventArgs) Handles DataGrid1.Selected IndexChanged
End Sub
Private Sub DataGrid1_ItemCommand (ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand Select Case e.CommandName Case "Delete" 'Response.Write (DataGrid1.DataKeys (e.Item.ItemIndex) ) MYDB.DELRECORD (DITAGRID1.DATAKEYS (E.Item.ItemIndex)) Case "Disp" response.redirect (String.Format ("Disp.aspx? Art_col_sub = {0}", DataGrid1.DataKeys (E.Item.ItemIndex) )) Bindgrid () end select end sub
Private Sub DataGrid1_ItemDataBound (ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then If Len ( E.Item.cells (5) .text)> 12 TEN E.Item.cells (5) .text = MID (E.Item.cells (5) .text, 1, 12) "...... "End If 'Dim btnDelete As ImageButton' btnDelete = CType (e.Item.FindControl (" btnDelete "), ImageButton) 'btnDelete.Attributes.Add (" onclick "," return confirm (' Warning: This will delete ALL records, Including All Content Pages and Users, Associated with this Community. ') ") end if End Subend Class