• 大小: 1.08MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-08-20
  • 语言: 其他
  • 标签:

资源简介

带数据库的,省市县的三级联动,是自己做的,好多公司面试题都是这个。

资源截图

代码片段和文件信息

using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
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 ProjectManage.DataAccesslayer;
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender EventArgs e)
    {
        AjaxPro.Utility.RegisterTypeForAjax(typeof(_Default));

        if (!IsPostBack)
        {
            setProvince();
            ListItem listCity = new ListItem(“请选择“ “-1“);
            ddlCity.Items.Insert(0 listCity);
            ListItem listArea = new ListItem(“请选择“ “-1“);
            ddlArea.Items.Insert(0 listArea);
        }

    }
    private void setProvince()
    {
        ddlProvince.DataSource = getdate();
        ddlProvince.DataTextField = “name“;
        ddlProvince.DataValueField = “pid“;
        ddlProvince.DataBind();
        ListItem listProvince = new ListItem(“请选择“ “-1“);
        ddlProvince.Items.Insert(0 listProvince);
    }

    public DataTable getdate()
    {
        string strSql = “select * from cepro“;
        return SqlHelper.ExecuteDataset(Class1.ConnectionString CommandType.Text strSql).Tables[0];
    }
    /// 
    /// 市
    /// 

    /// 
    /// 
    [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
    public string getParent(string parentID)
    {
        DataTable dtCity = getdate1(parentID);
        string strCity = ““;
        for (int i = 0; i < dtCity.Rows.Count; i++)
        {
            strCity += dtCity.Rows[i][“name“].ToString().Trim() + ““ + dtCity.Rows[i][“cid“].ToString().Trim() + “-“;
            if (i == dtCity.Rows.Count - 1) strCity = strCity.Substring(0 strCity.Length - 1);
        }
        return strCity;
    }
    /// 
    /// 县
    /// 

    /// 
    /// 
    [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
    public string getParentarea(string parentID)
    {
        DataTable dtCity = getdate2(parentID);
        string strCity = ““;
        for (int i = 0; i < dtCity.Rows.Count; i++)
        {
            strCity += dtCity.Rows[i][“name“].ToString().Trim() + ““ + dtCity.Rows[i][“cid“].ToString().Trim() + “-“;
            if (i == dtCity.Rows.Count - 1) strCity = strCity.Substring(0 strCity.Length - 1);
        }
        return strCity;
    }
    /// 
    /// 取市
    /// 

    /// 
    /// 
    public DataTable getdate1(string pid)
    {
        string strSql = “select * from cecity where pid=@pid“;
        SqlParameter[] _param =
        {
            new SqlParameter(“@pid“SqlDbType.VarChar)
        };
        _param[0].Value = pid;

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        774  2009-03-04 10:27  shengshixian\App_Code\Class1.cs

     文件      74401  2009-03-04 10:30  shengshixian\App_Code\SqlHelper.cs

     文件     143360  2007-11-20 16:46  shengshixian\bin\AjaxPro.2.dll

     文件         48  2009-03-04 10:24  shengshixian\bin\AjaxPro.2.dll.refresh

     文件       5289  2009-03-04 12:18  shengshixian\Default.aspx

     文件       6020  2009-03-04 12:12  shengshixian\Default.aspx.cs

     文件       2244  2009-03-04 11:17  shengshixian\Web.config

     目录          0  2009-03-04 10:30  shengshixian\App_Code

     目录          0  2009-03-04 10:24  shengshixian\App_Data

     目录          0  2009-03-04 10:24  shengshixian\bin

     目录          0  2009-03-04 21:31  shengshixian

     文件        774  2009-03-04 10:27  shengshixian\shengshixian\App_Code\Class1.cs

     文件      74401  2009-03-04 10:30  shengshixian\shengshixian\App_Code\SqlHelper.cs

     文件     143360  2007-11-20 16:46  shengshixian\shengshixian\bin\AjaxPro.2.dll

     文件         36  2009-03-04 19:51  shengshixian\shengshixian\bin\AjaxPro.2.dll.refresh

     文件       5294  2009-03-04 18:56  shengshixian\shengshixian\Default.aspx

     文件       6020  2009-03-04 12:12  shengshixian\shengshixian\Default.aspx.cs

     文件       2234  2009-03-04 19:46  shengshixian\shengshixian\Web.config

     目录          0  2009-03-04 10:30  shengshixian\shengshixian\App_Code

     目录          0  2009-03-04 10:24  shengshixian\shengshixian\App_Data

     目录          0  2009-03-04 10:24  shengshixian\shengshixian\bin

     目录          0  2009-03-04 21:31  shengshixian\shengshixian

     文件    3145728  2009-03-04 21:24  shengshixian\shengshixian\data\sheng.mdf

     文件    1048576  2009-03-04 21:24  shengshixian\shengshixian\data\sheng_log.ldf

     目录          0  2009-03-04 21:31  shengshixian\shengshixian\data

----------- ---------  ---------- -----  ----

              4658559                    25


评论

共有 条评论

相关资源