62,046
社区成员
发帖
与我相关
我的任务
分享
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// 第一个dropdownlist ,AutoPostBack="true"
this.ddl_Channel.DataSource = new BLL.NMG_Article_Channel().GetAllList();
this.ddl_Channel.DataTextField = "ch_name";
this.ddl_Channel.DataValueField = "ch_id";
this.ddl_Channel.DataBind();
}
if (!string.IsNullOrEmpty(this.ddl_Channel.SelectedValue))
{
ChannelNo = Convert.ToInt32(this.ddl_Channel.SelectedItem.Value);
bingClass(); //第二个
}
}
public void bingClass()
{
this.ddl_Class.Items.Clear();
if (!string.IsNullOrEmpty(ChannelNo.ToString()))
{
DataTable Dt = new BLL.NMG_Article_Class().GetNewsClass(ChannelNo).Tables[0];
for (int i = 0; i < Dt.Rows.Count; i++)
{
string c_id = Dt.Rows[i]["cl_id"].ToString();
string c_name = Dt.Rows[i]["cl_name"].ToString();
this.ddl_Class.Items.Add(new ListItem(c_name, c_id));
}
}
//这里第一个dropdownlist 如果选第一项,classno都为1,选其他正常
ClassN0 = Convert.ToInt32(this.ddl_Class.SelectedValue.ToString());
}
protected void ddl_Channel_SelectedIndexChanged(object sender, EventArgs e)
{
bingClass();
}