各位师兄帮忙GridView和DropDownList联动
usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingS...
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.SqlClient;
public partial class _Default : System.Web.UI.Page
{
SqlConnection sqlcon;
SqlCommand sqlcom;
SqlDataAdapter sd;
DataSet ds;
string sqlstr = "Data Source=192.168.1.104;Database=baoxian;Uid=sa;Pwd=123456";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.bindData() ;//绑定DropDownList
//string id = this.DropDownList1.SelectedValue;//获取当前DropDownList的value值
//this.BindToGridView(id); //绑定GridView
}
}
public void bindData()
{
SqlConnection sqlcon = new SqlConnection();
sqlcon.Open();
SqlDataAdapter sd = new SqlDataAdapter( "select * from PE_Nodes where NodeName ", sqlcon);
DataSet ds = new DataSet();
sd.Fill(ds);
this.DropDownList1.DataSource = ds;
this.DropDownList1.DataTextField = "NodeName";
this.DropDownList1.DataBind();
sqlcon.Close();
}
public void bindGridView(string id)
{
this.GridView1.AllowPaging = true;//允许分页
this.GridView1.AllowSorting = true;//允许排序
SqlDataAdapter sda1 = new SqlDataAdapter("select * from PE_Nodes where NodeName ", sqlcon);
DataSet ds = new DataSet();
sda1.Fill(ds);
this.GridView1.DataSource = ds;
this.GridView1.DataBind();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string id = this.DropDownList1.SelectedValue;//获取当前DropDownList的value值
this.bindData(id);
}
}
--------------------------------------------------
错误提示:
错误 1 “bindData”方法没有采用“1”个参数的重载 C:\Documents and Settings\Administrator\桌面\admin\Default.aspx.cs 62 9 C:\...\admin\
我是想在DropDownList中选定一个主题.然后在GridView中显示所有这个主题下打数据..默认DropDownList显示全部 DropDownList显示全部内容
希望好心打高手帮忙.如果有时间在哇源代码上修改下再发一下..加点注释.麻烦各位..小弟先谢啦 结贴时候还加分 展开
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.SqlClient;
public partial class _Default : System.Web.UI.Page
{
SqlConnection sqlcon;
SqlCommand sqlcom;
SqlDataAdapter sd;
DataSet ds;
string sqlstr = "Data Source=192.168.1.104;Database=baoxian;Uid=sa;Pwd=123456";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.bindData() ;//绑定DropDownList
//string id = this.DropDownList1.SelectedValue;//获取当前DropDownList的value值
//this.BindToGridView(id); //绑定GridView
}
}
public void bindData()
{
SqlConnection sqlcon = new SqlConnection();
sqlcon.Open();
SqlDataAdapter sd = new SqlDataAdapter( "select * from PE_Nodes where NodeName ", sqlcon);
DataSet ds = new DataSet();
sd.Fill(ds);
this.DropDownList1.DataSource = ds;
this.DropDownList1.DataTextField = "NodeName";
this.DropDownList1.DataBind();
sqlcon.Close();
}
public void bindGridView(string id)
{
this.GridView1.AllowPaging = true;//允许分页
this.GridView1.AllowSorting = true;//允许排序
SqlDataAdapter sda1 = new SqlDataAdapter("select * from PE_Nodes where NodeName ", sqlcon);
DataSet ds = new DataSet();
sda1.Fill(ds);
this.GridView1.DataSource = ds;
this.GridView1.DataBind();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string id = this.DropDownList1.SelectedValue;//获取当前DropDownList的value值
this.bindData(id);
}
}
--------------------------------------------------
错误提示:
错误 1 “bindData”方法没有采用“1”个参数的重载 C:\Documents and Settings\Administrator\桌面\admin\Default.aspx.cs 62 9 C:\...\admin\
我是想在DropDownList中选定一个主题.然后在GridView中显示所有这个主题下打数据..默认DropDownList显示全部 DropDownList显示全部内容
希望好心打高手帮忙.如果有时间在哇源代码上修改下再发一下..加点注释.麻烦各位..小弟先谢啦 结贴时候还加分 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询