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

首頁(yè) > 開發(fā) > XML > 正文

給初學(xué)的朋友們,datagrid用xml作為數(shù)據(jù)源,并且有更新,刪除和排序的操作(VB)

2024-09-05 20:55:51
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友


收集最實(shí)用的網(wǎng)頁(yè)特效代碼!

<%@ 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>


by the way, here is the xml source for this example:
run this code

<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>

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 久久一区三区 | 九九热精品在线视频 | 永久av在线免费观看 | 美国黄色毛片女人性生活片 | 精精国产xxxx视频在线野外 | 免费看真人a一级毛片 | 少妇一级淫片免费放正片 | 草碰人人 | 欧美性受xxxxxx黑人xyx性爽 | 久久国产精品区 | 国产高潮国产高潮久久久91 | 激情免费视频 | 91精品久久香蕉国产线看观看 | 国产精品久久久久久模特 | 中文字幕国产亚洲 | 亚洲电影在线播放 | 久久福利小视频 | 免费国产一级淫片 | 成年人在线免费 | 一级毛片免费一级 | 国产一区在线免费 | 国产一级免费视频 | 青青青在线免费 | japanesexxxxxxxhd | gril hd| 综合国产一区 | 国产精品毛片va一区二区三区 | v11av在线视频成人 | 黄色片网站免费观看 | 毛片av网址| 国产小视频在线 | 久久久www成人免费精品 | 免费国产一区 | 亚洲国产精品一区 | 久久人人爽人人爽人人片av高清 | 欧美日韩亚洲精品一区二区三区 | 免费99热在线观看 | 青青操国产 | 羞羞视频免费观看入口 | 国产三级a三级三级 | 色交视频 |