Datagrid cannot displayed.
-
Hie, All I want to display what is on the XML put on the datagrid at the same time, want a delete hyperlink to delete my user. How to do it? The Edit or Add function can ignore it or the best is delete it. Let's look at the coding. <%@ Import Namespace="System.IO" %> <%@ Import Namespace="System.Data" %> <%@ Page Language="VB" Inherits="System.Web.UI.Page" %> Delete User Account dim gXmlfile as string = "~/data/Users.xml" dim gXmlPath as string ' ================================= Sub Page_Load(Src As Object, E As EventArgs) gxmlpath = server.mappath( gXmlfile ) 'file is in same folder as page If Not (IsPostBack) DataLoad("UserEmail") End If End Sub ' ======================================== Sub DataLoad(parmsort as string) Dim ds As New DataSet Dim FS As New FileStream(Server.MapPath(gXmlFile), FileMode.Open) ds.ReadXml(FS) ' 02/14/02 pchu handle an empty file --------------------------- if ds.tables.count = 0 then ds.tables.add( MakeBooksTable() ) end if trace.warn ( "rowcount1 = " , cstr(ds.Tables(0).rows.count )) ' 02/14/02 pchu --------------------------- ' Add code to sort the dataview if parmsort is present 'ok let's get fancy and insert a blank row at the top dim sw1 as integer = 1 select case sw1 case 1 dim dr as datarow = ds.Tables(0).newrow() 'put something in the first column ISBN dr("UserEmail") = " Add UserEmail" ds.Tables(0).rows.insertat(dr, 0) trace.warn ( "rowcount2 = " , cstr(ds.Tables(0).rows.count )) end select 'create dv and bind it to datagrid dim dv as dataview dv = new DataView(ds.Tables(0)) if parmsort.length > 0 then dv.sort = parmsort end if MyDataGrid.DataSource = dv 'old MyDataGrid.DataSource = new DataView(ds.Tables(0)) ' 02/14/02 pchu --------------------------- MyDataGrid.DataBind() FS.close() END SUB ' ======================================== Sub DataSort(Src As Object, E As DataGridSortCommandEventArgs) ' Bug if we sort, then Edit Item Becomes Wrong IF MyDataGrid.EditItemIndex=-1 THEN DataLoad(e.sortexpression) ELSE response.write ("Can't sort until editing is done!") END IF End Sub Sub</x-turndown>