标题:DataList取某个单元格的值没取到
取消只看楼主
a5015576
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2012-9-24
 问题点数:0 回复次数:0 
DataList取某个单元格的值没取到
程序代码:
        <asp:DataList ID="DataList1" runat="server" RepeatColumns="6" RepeatDirection="Horizontal">
            <ItemTemplate>
                <table border="0" cellpadding="5" bgcolor="#0010a4" align="center" cellspacing="1">
                    <tr>
                        <td id="td2" runat="server" width="80" align="center" bgcolor="#6699ff">
                            <asp:Label ID="lbltel" Width="150px" runat="server" Text='<%# Bind("telno") %>'></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td width="80" align="center" bgcolor="white">
                            <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" />
                        </td>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:DataList>    string str;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            dbcom_src = db.GetSqlStringCommand("select telnoID,telno from M_TELNO where telnotrue=0");
            db.ExecuteNonQuery(dbcom_src);
            DataList1.DataSource = db.ExecuteDataSet(dbcom_src).Tables[0];
            DataList1.DataBind();
        }
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < DataList1.Items.Count; i++)
        {
            str = ((Label)DataList1.Items[i].FindControl("lbltel")).Text;
        }
        Response.Write(str);
       
    }

比如我点第一个单元格里的按钮,取到的是另一个单元格里的值,为啥会串行了呢?
搜索更多相关主题的帖子: border color 
2012-10-09 10:17



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-382759-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.217948 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved