我在html上绑定数据时遇到问题 [英] i am getting issue on binding data on html

查看:103
本文介绍了我在html上绑定数据时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我 - 我在html上绑定数据时遇到问题



html is-



can anybody please help me--i am getting issue on binding data on html

html is-

"

<div id="divmain" runat="server">
    <table>
                <tr>
                <td style="width:100px"><asp:LinkButton  ID="Label3" runat="server" ></asp:LinkButton></td>

                <td style="width:100px"><asp:LinkButton ID="Label4" runat="server" ></asp:LinkButton></td>
                <td style="width:100px"><asp:LinkButton ID="Label5" runat="server" ></asp:LinkButton></td>
                </tr>
            </table>
    </div>"









服务器端 -







server side-

SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["mystring"].ConnectionString.ToString());
       DataSet ds = new DataSet();
       SqlDataAdapter da = new SqlDataAdapter("Tbl_Data", con);
       da.Fill(ds, "tbl_1");
       da.SelectCommand.CommandType = CommandType.StoredProcedure;
       //LinkButton a = (LinkButton)DataList1.FindControl("Label3");
       //DataList1.DataSource = ds;
       //DataList1.DataBind();
       int i;
       for (i = 0; i < ds.Tables[0].Rows.Count; i++)
       {
           //Label3.Text = dr["name"].ToString();
           Label3.Text = ds.Tables[0].Rows[i]["name"].ToString();
           Label4.Text = ds.Tables[0].Rows[i]["actor"].ToString();
           Label5.Text = ds.Tables[0].Rows[i]["film"].ToString();

       }







这不绑定所有行只绑定最后一行



缺少添加的代码块




this is not binding all rows only binding last row

missing code block added

推荐答案

当然,所有时间它都会显示最后的结果,因为你使用的控件标签没有任何转发器。所以你正在使用的循环更新结果,最后显示最后的结果。请获取转发器并将数据源提供给表格。
Of course all time it will show the last result because you are using the control label without any repeater. So the loop you are using is updated it result and finally showing the last result. Please get a repeater and give the data source the table.


这篇关于我在html上绑定数据时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆