首页 新闻 会员 周边 捐助

asp.net用户控件在同一个页面多次使用不为什么只显示第一个!晕啊!请各位博友帮忙看看!

0
悬赏园豆:50 [已解决问题] 解决于 2011-07-30 11:14

通过iis编译后在浏览器上显示:

<div class="beijing_vacation">
            <ul class="main2_right_ul">
              <li><a class="pic_k" href="#"><img vspace="2" border="0" src="images/Lhasa2.jpg"><br>
                <p>Lhasa</p>
              </a></li>
              <li><a class="pic_k" href="#"><img vspace="2" border="0" src="images/nyingchi.jpg"><br>
                <p>Nyingchi</p>
              </a></li>
              <li><a class="pic_k" href="#"><img vspace="2" border="0" src="images/shigatse.jpg"><br>
                <p>Shigatse</p>
              </a></li>
              <li><a class="pic_k" href="#"><img vspace="2" border="0" src="images/lhoka.jpg"><br>
                <p>Lhoka</p>
              </a></li>
              <li><a class="pic_k" href="#"><img vspace="2" border="0" src="images/nagri.jpg"><br>
                <p>Nagri</p>
              </a></li>
              <li><a class="pic_k" href="#"><img vspace="2" border="0" src="images/gambo.jpg"><br>
                <p>Gambo</p>
              </a>
              <!-- <li><a href="/lhasa/">Lhasa</a></li><li><a href="/nyingchi/">Nyingchi</a></li><li><a href="/shigatse/">Shigatse</a></li><li><a href="/lhoka/">Lhoka</a></li><li><a href="/chamdo/">Chamdo</a></li><li><a href="/nagri/">Nagri</a></li><li><a href="/nagqu/">Nagqu</a></li><li><a href="/mt-everest/">Mt Everest</a></li> -->
            </li></ul>
            <div class="clear"></div>
            <dl>
              <p class="mian2_dl"><a href="/beijing/beijing-classic-tour-package.htm">Tibet Overland Tours </a><span>4 Tours</span></p>
              <dt><img src="images/Zhangmu1.jpg">
                <p>As one of six ancient capitals in China, Beijing will be your amazing destination. This historic city is best renowned for its magnificent imperial palaces, majestic temples, historic Hutongs and traditional courtyard residences together with numerous well-preserved relics of Old Beijing. </p>
              </dt>
              <ul>
                第一个用户控件显示的内容:----
<li><a href="/chinatour/classic-beijing-tour/ctt-07.htm">Overland Tour From Lhasa To Kathmandu with Mt.everest</a>From<strong> US$</strong></li>

<li><a href="/chinatour/classic-beijing-tour/.htm">Overland Tour From Qinghai To Tibet</a>From<strong> US$</strong></li>

<li><a href="/chinatour/classic-beijing-tour/.htm">Sichuan-Tibet tours via Highway --South Route </a>From<strong> US$</strong></li>
====结束
              </ul>
            </dl>
            <dl>
              <p class="mian2_dl"><a href="/beijing/beijing-coach-tours.htm">Lhasa Tours</a><span>4 Tours</span></p>
              <dt><img src="images/potala-palace2.jpg">
                <p>For budget reason it's a good choice to join in our Small Group Tour less than 18 persons. However this program still keeps its high-quality service and well-arranged itinerary for our clients. Furthermore, it's a wonderful experience of sharing with other travelers from the whole world in scenery sightseeing in a small group. </p>
              </dt>
              <ul>
                第二个在这个位置但是什么都没有
              </ul>
            </dl>
            <dl>
              <p class="mian2_dl"><a href="/beijing/beijing-half-day-tours.htm">Everest Base Camp Tours</a><span>4 Tours</span></p>
              <dt><img src="images/Everest-Base-Camp3.jpg">
                <p>Maybe you have to transfer in Capital Airport or you can to save some free time. If you are limited in time visiting many places of interest or just want to have a full exploration of Beijing in China, the tour Beijing in half day we designed for you would be the best choice. </p>
              </dt>
              <ul>
                第三个在这个位置但是什么都没有
              </ul>
            </dl>
            <dl>
              <p class="mian2_dl"><a href="/beijing/beijing-night-tours.htm">Mt Kailash Tours</a><span>1 Tours</span></p>
              <dt><img src="images/Mt.Kailash4.jpg">
                <p>Are you looking for Beijing night sightseeing tour, night events, or night shows? See Beijing when it sparkles - Olympic Stadium ( Bird Nest ), Water Cube, Beijing CBD &amp; SOHO Business Street, Ancient City Wall, Changan Street, Tiananmen Sqaure, National Grand Theatre, Beijing Bank Street ( China Wall Street ), and Houhai Lake Bar Street.</p>
              </dt>
              <ul>
                第四个在这个位置但是什么都没有
              </ul>
            </dl>
            <dl>
              <p class="mian2_dl"><a href="/beijing/beijing-side-trip.htm">Tibet Trekking Tours</a><span>0 Tours</span></p>
              <dt><img src="images/Yomdrok-Lake5.jpg">
                <p>If you are going to have a lifetime or just a regular trip to Beijing, we advise you to tear yourself away from the capital Beijing for a day ,or two or even more days to explore some of the easily accessible and wonderfully memorable spots and cities starting from and back to the capital city. </p>
              </dt>
              <ul>
                第五个在这个位置但是什么都没有
              </ul>
            </dl>
          </div>

用户控件里的内容:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="default.ascx.cs" Inherits="uc_default" %>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<li><a href="/chinatour/<%=url %>/<%#tool.dvHTMLEncode(Eval("code").ToString().Trim()) %>.htm"><%#Eval("title") %></a>From<strong> US$<%#Eval("price") %></strong></li>
</ItemTemplate>
</asp:Repeater>

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class uc_default : System.Web.UI.UserControl
{
    protected int _classid;
    protected string _url;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            bind();
        }
    }
    public int classid
    {
        set
        {
            _classid = value;
        }
        get
        {
            return _classid;
        }
    }
    public string url
    {
        set
        {
            _url = value;
        }
        get
        {
            return _url;
        }
    }
    protected void bind()
    {
        Data data = new Data();
        DataTable dt = data.select_letter_hot(classid);
        Repeater1.DataSource = dt;
        Repeater1.DataBind();
    }
}

这个是底层代码的方法:

    public DataTable select_letter_hot(int classid)
    {
        DataSet ds = SqlHelper.ExecuteDataset(connectionstring, CommandType.StoredProcedure, "select_letter_hot", new SqlParameter("@classid", classid));
        try
        {
            return ds.Tables[0];
        }
        catch
        {
            return null;
        }
    }

        public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );

            // Create & open a SqlConnection, and dispose of it after we are done
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();

                // Call the overload that takes a connection in place of the connection string
                return ExecuteDataset(connection, commandType, commandText, commandParameters);
            }
        }

        public static DataSet ExecuteDataset(string connectionString, string spName, params object[] parameterValues)
        {
            if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
            if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
           
            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes an array of SqlParameters
                return ExecuteDataset(connectionString, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteDataset(connectionString, CommandType.StoredProcedure, spName);
            }
        }

        public static DataSet ExecuteDataset(SqlConnection connection, CommandType commandType, string commandText)
        {
            // Pass through the call providing null for the set of SqlParameters
            return ExecuteDataset(connection, commandType, commandText, (SqlParameter[])null);
        }

        public static DataSet ExecuteDataset(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if( connection == null ) throw new ArgumentNullException( "connection" );

            // Create a command and prepare it for execution
            SqlCommand cmd = new SqlCommand();
            bool mustCloseConnection = false;
            PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection );
               
            // Create the DataAdapter & DataSet
            using( SqlDataAdapter da = new SqlDataAdapter(cmd) )
            {
                DataSet ds = new DataSet();

                // Fill the DataSet using default values for DataTable names, etc
                da.Fill(ds);
               
                // Detach the SqlParameters from the command object, so they can be used again
                cmd.Parameters.Clear();

                if( mustCloseConnection )
                    connection.Close();

                // Return the dataset
                return ds;
            }   
        }
      

        public static DataSet ExecuteDataset(SqlConnection connection, string spName, params object[] parameterValues)
        {
            if( connection == null ) throw new ArgumentNullException( "connection" );
            if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes an array of SqlParameters
                return ExecuteDataset(connection, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteDataset(connection, CommandType.StoredProcedure, spName);
            }
        }

问题补充:

用户控件的引用     

<dl>
              <p class="mian2_dl"><a href="/beijing/beijing-classic-tour-package.htm">Tibet Overland Tours </a><span><%=tourline(221) %> Tours</span></p>
              <dt><img src="images/Zhangmu1.jpg" />
                <p>As one of six ancient capitals in China, Beijing will be your amazing destination. This historic city is best renowned for its magnificent imperial palaces, majestic temples, historic Hutongs and traditional courtyard residences together with numerous well-preserved relics of Old Beijing. </p>
              </dt>
              <ul>
                <uc1:default ID="default1" runat="server" classid="221" url="classic-beijing-tour" />
              </ul>
            </dl>
            <dl>
              <p class="mian2_dl"><a href="/beijing/beijing-coach-tours.htm">Lhasa Tours</a><span><%=tourline(219)%> Tours</span></p>
              <dt><img src="images/potala-palace2.jpg" />
                <p>For budget reason it's a good choice to join in our Small Group Tour less than 18 persons. However this program still keeps its high-quality service and well-arranged itinerary for our clients. Furthermore, it's a wonderful experience of sharing with other travelers from the whole world in scenery sightseeing in a small group. </p>
              </dt>
              <ul>
                <uc1:default ID="default2" runat="server" classid="219" url="beijing-coach-tours" />
              </ul>
            </dl>
            <dl>
              <p class="mian2_dl"><a href="/beijing/beijing-half-day-tours.htm">Everest Base Camp Tours</a><span><%=tourline(220)%> Tours</span></p>
              <dt><img src="images/Everest-Base-Camp3.jpg" />
                <p>Maybe you have to transfer in Capital Airport or you can to save some free time. If you are limited in time visiting many places of interest or just want to have a full exploration of Beijing in China, the tour Beijing in half day we designed for you would be the best choice. </p>
              </dt>
              <ul>
                <uc1:default ID="default3" runat="server" classid="220" url="beijing-half-day-tours" />
              </ul>
            </dl>
            <dl>
              <p class="mian2_dl"><a href="/beijing/beijing-night-tours.htm">Mt Kailash Tours</a><span><%=tourline(223)%> Tours</span></p>
              <dt><img src="images/Mt.Kailash4.jpg" />
                <p>Are you looking for Beijing night sightseeing tour, night events, or night shows? See Beijing when it sparkles - Olympic Stadium ( Bird Nest ), Water Cube, Beijing CBD & SOHO Business Street, Ancient City Wall, Changan Street, Tiananmen Sqaure, National Grand Theatre, Beijing Bank Street ( China Wall Street ), and Houhai Lake Bar Street.</p>
              </dt>
              <ul>
                <uc1:default ID="default4" runat="server" classid="223" url="beijing-night-tours" />
              </ul>
            </dl>
            <dl>
              <p class="mian2_dl"><a href="/beijing/beijing-side-trip.htm">Tibet Trekking Tours</a><span><%=tourline(230)%> Tours</span></p>
              <dt><img src="images/Yomdrok-Lake5.jpg" />
                <p>If you are going to have a lifetime or just a regular trip to Beijing, we advise you to tear yourself away from the capital Beijing for a day ,or two or even more days to explore some of the easily accessible and wonderfully memorable spots and cities starting from and back to the capital city. </p>
              </dt>
              <ul>
                <uc1:default ID="default5" runat="server" classid="230" url="beijing-side-trip" />
              </ul>
            </dl>

浮云1的主页 浮云1 | 初学一级 | 园豆:2
提问于:2011-07-27 10:04
< >
分享
最佳答案
0

其他控件占位置没有?

收获园豆:45
杯具程序员 | 小虾三级 |园豆:1718 | 2011-07-27 11:19
没有占位置啊
浮云1 | 园豆:2 (初学一级) | 2011-07-27 15:09
其他回答(1)
0

这代码贴的眼乱。。。。

收获园豆:5
阿K&LiveCai | 园豆:514 (小虾三级) | 2011-07-27 10:17
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册