如何将类别与子类别相关联,并在网格视图中显示数据,并在 asp.net 中的数据库中绑定数据?
protected void Page_Load(object sender, EventArgs e)
{
{
if (Page.IsPostBack == false)
bind();
}
}
private void bind()
{
string subcat1 = "" + Session["subcat"];
SqlDataAdapter adp = new SqlDataAdapter("select * from catsubcat where subcategory='" + subcat1 + "' and category='electronics'", Class1.getconnectionstring());
DataSet ds = new DataSet();
adp.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}