2013-03-06 18 views
0

我無法讓SqlWhereBuilder.js使用我的數據庫中的值填充下拉列表。我已經指定了一個valueentry配置文件和一個相應的.ascx和.ascx.cs文件。我檢查了.ascx.cs文件中的查詢,並且它返回了我需要的值。但是我無法使用這些值填充我的網站過濾器功能中的下拉菜單。有什麼我在這裏失蹤..我使用這個控制權嗎?使用SqlWhereBuilder ASP.NET服務器控件填充數據庫中的值

我的fieldsfile和操作列表文件從xml正確填充。但只有來自數據庫的值不會填充。

我的.aspx文件:

<asp:Panel ID="panelContentCS" Style="overflow: hidden;" Width="650px" runat="server"> 
           <div id="LayerCS" style="padding-left: 20px; padding-bottom: 10px; padding-top: 10px; 
            padding-right: 10px;"> 
            <cc1:SqlWhereBuilder ID="swb1" runat="server" ClientCodeLocation="js/SqlWhereBuilder.js" 
             FieldsFile="Configuration/fields.config" OperatorListsFile="Configuration/operatorLists.config" 
             ValueEntryFile="Configuration/valueEntryDivs.config" NoConditionsText="Please Specify conditions" 
             ButtonStyle="font-size: 10pt; background:whitesmoke;border:2px; border-style:solidline;" 
             MainStyle="background-color:gainsboro;" ConditionCellStyle="border:1px solid black; padding:2px; background-color:#eeeeee" 
             EditButtonText="Edit" DeleteButtonText="Delete" AddButtonText=" Add " EditButtonsHiliteColor="Gray" 
             EditButtonsStyle="font-family: 'Arial'; font-size: 10pt; cursor:pointer;" ConditionDisplayStyle="font-family: 'Tahoma': font-size: 10pt; padding 2px;"> 
            </cc1:SqlWhereBuilder> 
           </div> 
          </asp:Panel> 

我valueEntryDivs.config:

<valueEntry id="vCodeR" userControl="SQLBuilder/CodeR.ascx" /> 
<valueEntry id="vCodeQ" userControl="SQLBuilder/CodeQ.ascx" /> 
<valueEntry id="vCodeT" userControl="SQLBuilder/CodeT.ascx" /> 

我CodeT.ascx:

<%@ Control Language="C#" AutoEventWireup="false" CodeFile="CodeT.ascx.cs"  Inherits="CodeT" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %> 
<asp:DropDownList id="ddCodeT" runat="server" DataValueField="CodeT" DataTextField="CodeT"></asp:DropDownList> 

我CodeT.ascx.cs:

public partial class CodeT : System.Web.UI.UserControl 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 
     int count = 0; 
     int j = 0; 

     DbDataReader rdr = null; 
     DbProviderFactory provider = Framework.ConnectionClass.GetDbFactory(); 
     DbConnection conn = null; 
     conn = Framework.ConnectionClass.GetConnection("Code"); conn.Open(); 
     DbCommand cmd = provider.CreateCommand(); 
     cmd.CommandText = "SELECT [VALUE] AS CodeT FROM tb_Searchcache WHERE LabelName = 'CodeT'"; 
     cmd.Connection = conn; 

     if (!this.IsPostBack) 
     { 
      try 
      { 
       rdr = Framework.DBClass.GetReader(ref cmd); 
       ddCodeT.DataSource = rdr; 
       ddCodeT.DataBind(); 
       count = ddCodeT.Items.Count; 
       while (j < count) 
       { 
        ddCodeT.Items[j].Value = "'" + ddCodeT.Items[j].Value + "'"; 
        j = j + 1; 
       } 
      } 
      finally 
      { 
       if ((rdr != null)) 
       { 
        rdr.Close(); 
       } 
       cmd.Dispose(); 
       if (conn.State != ConnectionState.Closed) 
        conn.Close(); 

      } 
     } 
    } 
} 

回答

0

在浪費了相當長的時間之後,我意識到我需要將 AutoEventWireup設置爲「true」。回發從未觸發過任何東西!

相關問題