如何使用下拉列表显示来自多个表的数据 [英] How to display data from more then one table using dropdown

查看:75
本文介绍了如何使用下拉列表显示来自多个表的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SqlDataAdapter da = new SqlDataAdapter("select p.rid,pf.uname,e.education from Personal p join Profile pf on p.rid=pf.rid join  education e on p.edu_id= e.edu_id where  e.education='"+edu.SelectedValue+"'", cn);
    
        //SqlDataAdapter da = new SqlDataAdapter("select image from uplodimage where rid=" + Session["rid"], cn);
        DataSet ds = new DataSet();
        da.Fill(ds);
       GridView1.DataSource = ds.Tables[0];
        GridView1.DataBind();





我尝试过:



SqlDataAdapter da = new SqlDataAdapter(select p.rid,pf.uname,e.education from Personal p join profile pf on p.rid = pf.rid join education e on p。 edu_id = e.edu_id其中e.education ='+ edu.SelectedValue +',cn);



// SqlDataAdapter da = new SqlDataAdapter(select image from uplodimage where rid =+ Session [rid],cn);

DataSet ds = new DataSet();

da.Fill(ds);

GridView1.DataSource = ds.Tables [0];

GridView1.DataBind();



What I have tried:

SqlDataAdapter da = new SqlDataAdapter("select p.rid,pf.uname,e.education from Personal p join Profile pf on p.rid=pf.rid join education e on p.edu_id= e.edu_id where e.education='"+edu.SelectedValue+"'", cn);

//SqlDataAdapter da = new SqlDataAdapter("select image from uplodimage where rid=" + Session["rid"], cn);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();

推荐答案



我对你的问题的理解是,你必须根据下拉列表中的选定值绑定网格。

如果是这样,那么edu.SelectedValue是不正确。

如果dropdownlist id是dropdownlist1,那么where条件将是dropdownlist1.SelectedItem.Value或dropdownlist1.SelectedItem.Text







Hi,
My understanding of your question is, you have to bind the grid based on the selected value in the dropdownlist.
If it is so, then "edu.SelectedValue" is not correct.
if the dropdownlist id is "dropdownlist1" then the where condition will be "dropdownlist1.SelectedItem.Value" or dropdownlist1.SelectedItem.Text



SqlDataAdapter da = new SqlDataAdapter("select p.rid,pf.uname,e.education from Personal p join Profile pf on p.rid=pf.rid join  education e on p.edu_id= e.edu_id where  e.education='"+dropdownlist1.SelectedItem.Value+"'", cn);


这篇关于如何使用下拉列表显示来自多个表的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆