動態載入省市區

2021-09-27 09:16:24 字數 2698 閱讀 7906

資料庫表結構:

sql語句:

create table [cascade]

(id int,

name nvarchar(50),

parentid int,

[type] int

)

//aspx**省:

市:區:

//js**

$(document).ready(function ()

else ],

valuefield: 'id',

textfield: 'text',

editable: true

})$("#city").combobox("setvalue", -1)}}

})$("#province").combobox("setvalue", -1)

//市$('#city').combobox(],

valuefield: 'id',

textfield: 'text',

editable: true,

onchange: function (n, o)

else ],

valuefield: 'id',

textfield: 'text',

editable: true

})$("#area").combobox("setvalue", -1)}}

})$("#city").combobox("setvalue", -1)

//區$('#area').combobox(],

valuefield: 'id',

textfield: 'text',

editable: true

})$("#area").combobox("setvalue", -1);

});//end ready

//繫結市

function getcity(parentid) );

$("#city").combobox("setvalue", -1)

getarea(parentid);

},error: function ()

})}//繫結區

function getarea(parentid) );

$("#area").combobox("setvalue", -1);

},error: function () })}

**

protected void page_load(object sender, eventargs e)

response.end();

}/// /// 查省

///

///

public string getprovince()

); lst.addrange(dt.asenumerable().select(p => new

).tolist());

return jsonconvert.serializeobject(lst);

}/// /// 查市

///

private void getcity()

); lst.addrange(dt.asenumerable().select(p => new

).tolist());

response.write(jsonconvert.serializeobject(lst));

}/// /// 查區

///

///

public void getarea()

); lst.addrange(dt.asenumerable().select(p => new

).tolist());

response.write(jsonconvert.serializeobject(lst));

}

**//連線字串

static string strconn = configurationmanager.connectionstrings["cnnhorechargeplatformconnectionstring"].tostring();

/// /// 執行查詢,返回datatable物件

///

/// sql語句

/// datatable物件

public static datatable gettable(string strsql)

return dt;

}/// /// 查省

///

/// 型別

///

public static datatable getprovince(int type)

/// /// 查市/區

///

/// 型別

/// 父級id

///

public static datatable getcityarea(int type, int parentid)

and parentid= ", type, parentid);

return gettable(sql);

}

全國省市區資料SQL 省市區

drop table if exists provinces create table provinces id int 11 not null auto increment,provinceid varchar 20 not null,province varchar 50 not null,pr...

省市區陣列

先找到檔案對應的路徑 nsstring path users dlios desktop oc5 省市區陣列 oc5 省市區陣列 area.txt 通過路徑產生字串,內容就是txt文字裡的內容 nsstring str nsstring stringwithcontentsoffile path e...

OC 省市區陣列

省市區陣列 先找到檔案對應的路徑 nsstring path users dlios desktop 筆記 oc筆記 oc5 陣列省市區 oc5 陣列省市區 area.txt 通過路徑產生字串,內容就是txt文字的內容 nsstring str nsstring stringwithcontents...