徐虎的专栏

xuhu Email:xuandhu@126.com QQ:41172837

datalist我的示例

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">  
    Sub DataList1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs)
        If e.CommandSource.ID = "LinkButton1" Then
            DataList1.SelectedIndex = e.Item.ItemIndex
            ' ElseIf e.CommandSource.ID = "LinkButton2" Then
         
            ' ElseIf e.CommandSource.ID = "LinkButton4" Then
            '    DataList1.EditItemIndex = e.Item.ItemIndex
        ElseIf e.CommandSource.ID = "LinkButton3" Then
            DataList1.EditItemIndex = -1
        ElseIf e.CommandSource.ID = "LinkButton5" Then
            Response.Write("hello")
        End If
       
        DataList1.DataBind()
    End Sub

    Sub DataList1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs)
        DataList1.EditItemIndex = e.Item.ItemIndex
        DataList1.DataBind()
    End Sub

    Sub DataList1_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs)
        Response.Write("this is test..................dingding")
        DataList1.SelectedIndex = -1
        DataList1.DataBind()
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DataList ID="DataList1" Runat="server" DataKeyField="ID" DataSourceID="AccessDataSource1" OnItemCommand="DataList1_ItemCommand" OnEditCommand="DataList1_EditCommand" OnCancelCommand="DataList1_CancelCommand">
            <SelectedItemTemplate>
                  ID:
                <asp:Label ID="Label1" Runat="server" Text='<%# Eval("ID") %>'></asp:Label>&nbsp;
                <br />
                art_title:
                <asp:Label ID="Label2" Runat="server" Text='<%# Eval("art_title") %>'></asp:Label><br />
                IP:
                <asp:Label ID="Label3" Runat="server" Text='<%# Eval("IP") %>'></asp:Label>
                <asp:LinkButton ID="LinkButton2" Runat="server" CommandName="cancel">return</asp:LinkButton>
                <asp:LinkButton ID="LinkButton4" Runat="server" CommandName="edit">edit</asp:LinkButton>
                <br />
                <br />
            </SelectedItemTemplate>
            <ItemTemplate>
                ID:
                <asp:Label ID="IDLabel" Runat="server" Text='<%# Eval("ID") %>'></asp:Label>
                <asp:LinkButton ID="LinkButton1" Runat="server" >more</asp:LinkButton>
                <br />
                <br />
            </ItemTemplate>
            <EditItemTemplate>
                  ID:&nbsp;&nbsp;
                <asp:TextBox ID="TextBox1" Runat="server" Text='<%# Eval("ID") %>'></asp:TextBox>
                <br />
                art_title:&nbsp;
                <asp:TextBox ID="TextBox2" Runat="server" Text='<%# Eval("art_title") %>'></asp:TextBox>
                <br />
                IP:&nbsp;
                <asp:TextBox ID="TextBox3" Runat="server" Text='<%# Eval("IP") %>'></asp:TextBox>
                <br /><asp:LinkButton ID="LinkButton3" Runat="server">CANCER</asp:LinkButton>
                <asp:LinkButton ID="LinkButton5" Runat="server">SUBMIT</asp:LinkButton>
                <br />
            </EditItemTemplate>
        </asp:DataList>
        <asp:AccessDataSource ID="AccessDataSource1" Runat="server" DataFile="~/Data/database.mdb"
            SelectCommand="SELECT [ID], [art_title], [IP] FROM [articles]">
        </asp:AccessDataSource>
   
    </div>
    </form>
</body>
</html>

阅读更多
个人分类: ASP.NET数据处理
想对作者说点什么? 我来说一句

datalist分页

2008年07月17日 4KB 下载

datalist简单用法

2015年11月20日 33KB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭