读书人

(2)二级无联动刷新就差一点点了请

发布时间: 2012-01-13 22:43:30 作者: rapoo

(2)二级无联动刷新,就差一点点了,请高手指点一下(代码简短有详细注释并可调试)
不好意思,由于代码太长,Sql和aspx放在了前面一贴,地址为:
http://topic.csdn.net/u/20080715/15/da00d90c-9e85-40cf-bec3-c0fe8809a233.html

【DDL2JiLianDong.aspx.cs】

C# code
using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.OracleClient;public partial class DDL2JiLianDong : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {        BindDrop();//如果不是提交回来就绑定列表框        dListChild.Attributes.Add("onFocus", "" + this.myHidden.ClientID + ".value=this.options[this.selectedIndex].value");        dListChild.Attributes.Add("onChange", "" + this.myHidden.ClientID + ".value=this.options[this.selectedIndex].value");        dListChild.Attributes.Add("onBlur", "" + this.myHidden.ClientID + ".value=this.options[this.selectedIndex].value");     }    protected void BindDrop()    {        //获得传递过来的parent_id值,如果是第一次请求他为null        string str = Request.QueryString["parent_id"];        string str1 = dListParent.SelectedValue; ;        //如果str加个字符串!=原来的字符串则说明触发过dListParent的onchange事件        if ((str + "abc") != "abc")        {            //绑定 dListChild控件            BindChild(str);//把传来的父DropDownList的value做为参数        }    }    protected void BindChild(string str)    {        //通过js给包括dropdownlist任何控件添加的内容不会被保存状态        //把参数转化成int        int i = Convert.ToInt32(str);        //定义个字符串用保存从数据库返回的数据        string result = "";        //先清空输出的东西        Response.Clear();        string connStr = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();        OracleConnection conn = new OracleConnection(connStr);        string commStr = string.Format("select type_value,type_text from kout_phone_type where parent_id = {0}", i);        OracleCommand comm = new OracleCommand(commStr, conn);        conn.Open();        OracleDataReader dr = comm.ExecuteReader();        while (dr.Read())        {            result += "," + dr[0].ToString() + "|" + dr[1].ToString();            //dListChild.Items.Add(new ListItem(dr[1].ToString(),dr[0].ToString()));        }        //把从数据库得到的信息输出到客户端        Response.Write(result);        //输出完成关闭Response,以免造成不必要的输出        Response.Flush();        Response.Close();        dr.Close();        conn.Close();    }    protected void Button1_Click(object sender, EventArgs e)    {        //Response.Write(Request.Form["dListChild"].ToString());        lblParentValue.Text = dListParent.SelectedValue.ToString();        //lblChildValue.Text = dListChild.SelectedValue.ToString();        lblChildValue.Text = this.myHidden.Value;    }}


[解决办法]
You can't delete any more after you replied it...

读书人网 >asp.net

热点推荐