首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 培训 数据库 书店 程序员
中国软件网
欢迎您:游客 | 登录 注册 帮助
  • 请高手帮忙!!!!
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-10 16:40:27 楼主
    点击DataList其中的一条记录..在lable显示相对应的数据,如何实现?

    20  修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-10 16:43:351楼 得分:0
    <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text=' <%# Eval("xxx") %>'> </asp:Label>
    </ItemTemplate>
    先绑定数据给DataList。。
    xxx 为字段名称
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-10 16:44:542楼 得分:0
    用js写双击事件
    C# code
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='#FFFFFF';this.style.color='#336699'"); e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#228ECE';this.style.color='#FF0000'"); e.Row.Attributes.Add("OnDblClick", "DbClickEvent('" + ((System.Data.DataRowView)(e.Row.DataItem)).Row.ItemArray[1] + "','" + Gcmc + "','" + Conn + "')"); e.Row.Attributes["style"] = "Cursor:hand"; } }
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-10 16:47:363楼 得分:0
    引用 1 楼 tautaulee 的回复:
      <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text=' <%# Eval("xxx") %>'> </asp:Label>
    </ItemTemplate>
    先绑定数据给DataList。。
    xxx 为字段名称

    //我看错了lz的问题。 sorry!!!!!
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-10 16:47:474楼 得分:0
    跟着呢..?
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-10 16:47:525楼 得分:0
    sorry!
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-10 16:49:066楼 得分:0
    不好意思..C#我没学..要VB.net
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-10 16:50:467楼 得分:0
    引用 2 楼 maco_wang 的回复:
    用js写双击事件

    C# code
      protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='#FFFFFF';this.style.color='#336699'");
                e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#228ECE';this.style.c…
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • zengxie
    • 等级:
    发表于:2008-05-10 16:51:108楼 得分:0
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                for (int i = 0; i < e.Row.Cells.Count; i++)
                {
                    e.Row.Cells[i].Attributes.Add("onclick","returnvalue('"+e.Row.Cells[i].Text+"')");
                }
            }
        }
    在写JS函数
    function returnvalue(aa)
    {
      document.getElementById("你的Lable的ID").value=aa;
    }
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • ysn1314
    • 等级:
    发表于:2008-05-10 16:52:039楼 得分:0
    用JS好像可以吧?
    在要点的数据上面加个onclick('值')方法
    然后 JS方法 document.getElementById('label ID').innerHTML = '值';
    楼主试下,我记得我以前是这么做的
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-10 16:58:1910楼 得分:0
    各位...我要的是DataList 里面放了linkbutton...
    点击linkbutton调用数据显示在lable的事件代码.....
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • Sandy945
    • 等级:
    发表于:2008-05-10 17:43:4311楼 得分:0
    HTML code
    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="DataList.aspx.vb" Inherits="DataList" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>无标题页</title> <script> parent.parent </script> </head> <body> <form id="form1" runat="server"> <div> <asp:DataList ID='dl' runat="server"> <ItemTemplate> <asp:Literal ID='lit' Text='<%#Eval("Name") %>' runat="server"></asp:Literal> <asp:LinkButton ID='lbtn' Text='click me' OnClick="lbtn_Click" runat="server"></asp:LinkButton> </ItemTemplate> </asp:DataList> <asp:Literal ID='showLit' runat="server"></asp:Literal> </div> </form> </body> </html>


    VB.NET code
    Partial Class DataList Inherits System.Web.UI.Page Protected Function getDataTable() As Data.DataTable Dim dt As New System.Data.DataTable() Dim dr As System.Data.DataRow dt.Columns.Add(New System.Data.DataColumn("ID", GetType(Integer))) dt.Columns.Add(New System.Data.DataColumn("Name", GetType(String))) dr = dt.NewRow() dr(0) = 1 dr(1) = "小明" dt.Rows.Add(dr) dr = dt.NewRow() dr(0) = 2 dr(1) = "小强" dt.Rows.Add(dr) dr = dt.NewRow() dr(0) = 3 dr(1) = "小张" dt.Rows.Add(dr) dr = dt.NewRow() dr(0) = 4 dr(1) = "小李" dt.Rows.Add(dr) dr = dt.NewRow() dr(0) = 5 dr(1) = "小关" dt.Rows.Add(dr) Return dt End Function Protected Sub lbtn_Click(ByVal sender As Object, ByVal e As EventArgs) Dim lbtn As LinkButton = TryCast(sender, LinkButton) Dim lit As Literal = TryCast(lbtn.Parent.FindControl("lit"), Literal) If lit IsNot Nothing Then showLit.Text = lit.Text End If End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then dl.DataSource = getDataTable() dl.DataBind() End If End Sub End Class
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-12 07:56:5512楼 得分:0
    收到你的留言,特来看看
    楼上正解!
    修改 删除 举报 引用 回复

    网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
    世纪乐知(北京)网络技术有限公司 版权所有 京 ICP 证 020026 号
    Copyright © 2000-2007, CSDN.NET, All Rights Reserved