C# con.Dispose(); } } 如果您自己在远程服务器上运行查询,会得到与在本地服务器上相同的结果吗?输出会以相同的查询传入localhost服务器,但回发后不会传入其他服务器。我想知道问题是否来自数据库表中的数据(远程服务器上的数据不同)。为了检查

C# con.Dispose(); } } 如果您自己在远程服务器上运行查询,会得到与在本地服务器上相同的结果吗?输出会以相同的查询传入localhost服务器,但回发后不会传入其他服务器。我想知道问题是否来自数据库表中的数据(远程服务器上的数据不同)。为了检查,c#,asp.net,C#,Asp.net,con.Dispose(); } } 如果您自己在远程服务器上运行查询,会得到与在本地服务器上相同的结果吗?输出会以相同的查询传入localhost服务器,但回发后不会传入其他服务器。我想知道问题是否来自数据库表中的数据(远程服务器上的数据不同)。为了检查这一点,您可以在远程服务器上测试查询,而不使用您的应用程序。查询正在另一台服务器上运行。但是数据不会绑定到第二个dropdownlist。 <form id="form1" runat="server"> <d

con.Dispose(); } }
如果您自己在远程服务器上运行查询,会得到与在本地服务器上相同的结果吗?输出会以相同的查询传入localhost服务器,但回发后不会传入其他服务器。我想知道问题是否来自数据库表中的数据(远程服务器上的数据不同)。为了检查这一点,您可以在远程服务器上测试查询,而不使用您的应用程序。查询正在另一台服务器上运行。但是数据不会绑定到第二个dropdownlist。
<form id="form1" runat="server">
        <div style="padding-left:100px;padding-top:30px;">
           <table align="left" class="auto-style1">
             <tr>
                <td>

                 <table  border="0" class="auto-style3" cellspacing="0"     cellpadding="10" margin-left: "40px">


            <tr>
                <td class="auto-style4">
                    <asp:Label ID="Label2" runat="server" Text="Select Topic" Font-Size="Medium"></asp:Label>
                        </td>
                        <td>
                            <asp:DropDownList ID="topicddl1" runat="server" Width="164px" Height="20px" AutoPostBack = "true"
             OnSelectedIndexChanged="topicddl1_SelectedIndexChanged">
               <asp:ListItem Text = "--Select Topic--" Value = ""></asp:ListItem>
                                </asp:DropDownList>



                        </td>
                    </tr>
                    <tr>
                        <td class="auto-style4">
                            Select Subtopic</td>
                        <td>
                            <asp:DropDownList ID="topicddl2" runat="server" Width="164px" Height="20px" AutoPostBack = "True"
             OnSelectedIndexChanged="topicddl2_SelectedIndexChanged">
               <asp:ListItem Text = "--Select Sub-Topic--" Value = ""></asp:ListItem>
                                </asp:DropDownList>

                        </td>
                    </tr>
                    <tr>
                        <td class="auto-style4">
                            Select Sub-Sub Topic</td>
                        <td>
                            <asp:DropDownList ID="topicddl3" runat="server" Width="164px" Height="20px" AutoPostBack = "True"
             OnSelectedIndexChanged="topicddl3_SelectedIndexChanged">
               <asp:ListItem Text = "--Select Sub-Topic--" Value = ""></asp:ListItem>
                                </asp:DropDownList>
                        </td>
                    </tr>
</table>
</div>
</form>

    # This is my backend code #



    public partial class edit : System.Web.UI.Page
    {
        string strcon = ConfigurationManager.ConnectionStrings["SPSConnectionString"].ConnectionString;
        SqlDataAdapter da;
        SqlConnection con;
        DataSet ds = new DataSet();
        SqlCommand cmd = new SqlCommand();
        string qry;
        SqlDataReader dr;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                topicddl1.AppendDataBoundItems = true;
                string strcon = ConfigurationManager.ConnectionStrings["SPSConnectionString"].ConnectionString;

                con = new SqlConnection(strcon);

                String strQuery = "select topic_name from topic group by topic_name order by min(sort_id) ";
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = strQuery;
                cmd.Connection = con;
                try
                {
                    con.Open();
                    topicddl1.DataSource = cmd.ExecuteReader();
                    topicddl1.DataTextField = "topic_name";
                    topicddl1.DataValueField = "topic_name";
                    topicddl1.DataBind();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    con.Close();
                    con.Dispose();
                }
            }
        }

        protected void topicddl1_SelectedIndexChanged(object sender, EventArgs e)
        {

            topicddl2.Items.Clear();
            topicddl2.Items.Add(new ListItem("--Select Sub-Topic--", ""));
            topicddl3.Items.Clear();
            //'(" + topicddl1.SelectedValue + ")'
            topicddl3.Items.Add(new ListItem("--Select Sub-Sub Topic--", ""));

            topicddl2.AppendDataBoundItems = true;


            con = new SqlConnection(strcon);

            String strQuery = "select sub_topic from topic group by topic_name,sub_topic having  topic_name= '" + topicddl1.SelectedItem.Text + "' order by min(sort_id) ";
            SqlCommand cmd = new SqlCommand();

            cmd.Parameters.AddWithValue("@topic_name",
                topicddl1.SelectedItem.Value);
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = strQuery;
            cmd.Connection = con;
            try
            {
                con.Open();
                topicddl2.DataSource = cmd.ExecuteReader();
                topicddl2.DataTextField = "sub_topic";

                topicddl2.DataValueField = "sub_topic";
                topicddl2.DataBind();
                if (topicddl2.Items.Count > 1)
                {
                    topicddl2.Enabled = true;
                }
                else
                {
                    topicddl2.Enabled = false;
                    topicddl2.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
                con.Dispose();
            }


        }

        protected void topicddl2_SelectedIndexChanged(object sender, EventArgs e)
        {

            topicddl3.Items.Clear();
            topicddl3.Items.Add(new ListItem("--Select Sub-Sub-Topic--", ""));
            topicddl3.AppendDataBoundItems = true;
            string strcon = ConfigurationManager.ConnectionStrings["SPSConnectionString"].ConnectionString;

            con = new SqlConnection(strcon);

            String strQuery = "select subsub_topic from topic group by sub_topic,subsub_topic having sub_topic='" + topicddl2.SelectedItem.Text + "' order by min(sort_id)";
            SqlCommand cmd = new SqlCommand();

            cmd.Parameters.AddWithValue("@sub_topic",
                                 topicddl2.SelectedItem.Value);
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = strQuery;
            cmd.Connection = con;
            try
            {
                con.Open();
                topicddl3.DataSource = cmd.ExecuteReader();
                topicddl3.DataTextField = "subsub_topic";

                topicddl3.DataValueField = "subsub_topic";
                topicddl3.DataBind();
                if (topicddl3.Items.Count > 1)
                {
                    topicddl3.Enabled = true;
                }
                else
                {
                    topicddl3.Enabled = false;
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
                con.Dispose();
            }
        }