麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 開發 > XML > 正文

將xml作為DataGrid 操作(Sort, Edit, delete)

2024-09-05 20:55:44
字體:
來源:轉載
供稿:網友

我們將顯示如何將一個xml文件作為datagrid,這樣對其的排序,編輯,等操作將是非常簡單的事。
<%@ import namespace="system.io" %>
<%@ import namespace="system.data" %>
<html>
<script language="vb" runat="server">

sub page_load(src as object, e as eventargs)
        if not (ispostback)
            dataload("isbn")
        end if
end sub

sub dataload(parmsort as string)
         dim ds as new dataset
        dim fs as new filestream(server.mappath("books.xml"), filemode.open)
        ds.readxml(fs)
        mydatagrid.datasource = new dataview(ds.tables(0))
        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 datadelete(sender as object, e as datagridcommandeventargs)
    dim deletekey as string
    if mydatagrid.edititemindex=-1 then
        deletekey=mydatagrid.datakeys(cint(e.item.itemindex))
        response.write ("deleted " & deletekey)
    else
        response.write ("can't delete until editing is done!")
    end if
end sub


sub dataedit(sender as object, e as datagridcommandeventargs)
        dim editkey as string
        mydatagrid.edititemindex = cint(e.item.itemindex)
        editkey=mydatagrid.datakeys(cint(e.item.itemindex))
        'response.write ("to be edited" & editkey)
        dataload("")
end sub

sub datacancel(sender as object, e as datagridcommandeventargs)
        mydatagrid.edititemindex = -1
        response.write ("edit was cancelled")
        dataload("")
end sub

sub dataupdate(sender as object, e as datagridcommandeventargs)
        dim editkey as string
        mydatagrid.edititemindex = -1
       editkey = mydatagrid.datakeys(cint(e.item.itemindex))
       response.write ("to be updated " & editkey)
        dataload("")
       ' howmanycols = e.item.cells.count
end sub

</script>

<body>

<h3><font face="verdana">the best books ever</font>
<span runat="server" id="myspan"/></h3>

<form runat="server">
<asp:datagrid id="mydatagrid" runat="server"

   allowsorting="true"
   onsortcommand="datasort"
   ondeletecommand="datadelete"
   oneditcommand="dataedit"
   oncancelcommand="datacancel"
   onupdatecommand="dataupdate"   
   
    datakeyfield="isbn"

   width="100%"
   backcolor="white"
   bordercolor="black"
   showfooter="false"
    cellpadding=3
   cellspacing="0"
   font-name="verdana"
   font-size="8pt"
   headerstyle-backcolor="lightblue"
   headerstyle-font-size="10pt"
   headerstyle-font-style="bold"
   maintainstate="true"
    >

     
     
    <columns>
      <asp:buttoncolumn text="delete book" commandname="delete"/>
     
      <asp:editcommandcolumn edittext="edit" canceltext="cancel" updatetext="update" itemstyle-wrap="false"/>
    </columns>
</asp:datagrid>

</form>
    
</body>
</html>
xml的源文件:
<books>
    <book>
    <isbn>0070653623</isbn>
    <author>jack trout, steve rivkin</author>
    <title>the power of simplicity</title>
    <category>selfhelp</category>
    <comments>a real fun read</comments>
    </book>
    
    <book>
    <isbn>0887306667</isbn>
    <author>al reiss, jack trout</author>
    <title>22 immutable laws of marketing</title>
    <category>marketing</category>
    <comments>this team offers more profound advice about creating world class marketing campaigns that will be viable for a hundred years.</comments>
    </book>

    <book>
    <isbn>0887309372</isbn>
    <author>al reiss, laura reiss</author>
    <title>22 immutable laws of branding</title>
    <category>marketing</category>
    <comments>this book is great for people who used 22 immutable laws of marketing to build a brand and now want to strengthen that brand.</comments>
    </book>
    
    <book>
    <isbn>0679757651</isbn>
    <author>tom peters</author>
    <title>circle of innovation</title>
    <category>marketing</category>
    <comments>his most recent book is his best by far!</comments>
    </book>
    
    <book>
    <isbn>0884270610</isbn>
    <author>eli goldthrait</author>
    <title>the goal</title>
    <category>management</category>
    <comments>advocate of theory of constraints as applied to managment and optimization.</comments>
    </book>

    <book>
    <isbn>068485600x</isbn>
    <author>jeff cox, howard stevens</author>
    <title>selling the wheel</title>
    <category>management</category>
    <comments>excellent treatise/novel on the entire sales cycle</comments>
    </book>

    <book>
    <isbn>0672316498</isbn>
    <author>alan cooper</author>
    <title>the inmates are running the asylum</title>
    <category>management</category>
    <comments>the father of visual basic and creator of the new art of interaction design - very valuable in designing websites. basically the worlds most  cutting edge thinker in user interface design aimed at simplifying software use.</comments>
    </book>
    
</books>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 国产精品一区在线观看 | 欧美成人精品欧美一级乱黄 | 精品国产一区二区三区在线观看 | 国产精品成人久久久久a级 av电影在线免费 | 久久欧美亚洲另类专区91大神 | 中文国产在线视频 | 日本高清在线免费 | 国产正在播放 | 天天好比网 | 4p一女两男做爰在线观看 | 国产精品美女一区二区 | 蜜桃91麻豆| 国产精品久久久久久久久久 | 欧美一级全黄 | 黄色片网站免费观看 | 久久久久久久久久综合 | 国产呻吟| 斗罗破苍穹在线观看免费完整观看 | 国产亚色| 欧美三日本三级少妇三级99观看视频 | 日本羞羞影院 | 特级毛片a级毛片100免费 | 国产流白浆高潮在线观看 | 成人在线视频免费 | 可以免费看av| 欧美日韩在线播放一区 | 深夜福利久久久 | 又黄又爽又色无遮挡免费 | 色婷婷久久久 | 九九视频精品在线观看 | 欧美区在线 | av在线免费看网址 | 久久亚洲精品久久国产一区二区 | 欧美亚洲国产成人 | 嗯~啊~用力~高h | 午夜视频啊啊啊 | 国产精品久久久久久久久久久久久久久 | 国产一级大片 | 精品一区二区久久久 | 久久艹精品视频 | 免费看日产一区二区三区 |