kkjkl
ljl
kjlkjl
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 DAL;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;
public partial class addList : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
init();
}
public string stateName
{
get
{
if (stateList.SelectedIndex <= 0)
{
return null;
}
else
{
return stateList.SelectedItem.Text;
}
}
}
public string stateId
{
get
{
if (stateList.SelectedIndex <= 0)
{
return null;
}
else
{
return stateList.SelectedValue;
}
}
}
public string subSateName
{
get
{
if (subName.Value != "" && subName.Value.IndexOf("所有区") == -1)
return subName.Value.Split('-')[0];
else
return null;
}
}
public string subSateId
{
get
{
if (subName.Value != "" && subName.Value.IndexOf("所有区") == -1)
return subName.Value.Split('-')[1];
else
return null;
}
}
public SqlDataReader dr2 = null;
void init()
{
DataSet dr = DAL.SqlHelper.Query("select distinct trade_id,trade_name from dbo.enterprise_Trade_sub");
stateList.DataSource = dr;
stateList.DataTextField = "trade_name";
stateList.DataValueField = "trade_id";
stateList.DataBind();
stateList.Items.Insert(0, new ListItem("所有城市", "0"));
dr2 = DAL.SqlHelper.ExecuteReader("select distinct trade_sub_id,trade_sub_name, trade_id,trade_name from dbo.enterprise_Trade_sub");
int indx = 0;
if (dr2 != null)
{
StringBuilder sb = new StringBuilder();
while (dr2.Read())
{
sb.Append("states[");
sb.Append(indx);
sb.Append("]=new subState(");
sb.Append(dr2["trade_sub_id"].ToString());
sb.Append(",'");
sb.Append(dr2["trade_sub_name"].ToString());
sb.Append("',");
sb.Append(dr2["trade_id"].ToString());
sb.Append(");");
indx++;
}
str.Value = sb.ToString();
dr2.Close();
}
}
}