当我点击生成按钮输出以在gridview中显示 [英] when i click the generate button output to be shown in gridview
问题描述
学生表
student table
Studid Bfid Rate
A 1 Good
B 2 Fair
C 3 Excellent
批处理表
Batch table
Bfid Class
1 EFA
2 MFA
3 COC
代码如下;
Code as follows;
sql = "Select studid,Bfid,Rate from student";
dr = scon.readsql(sql);
while(dr.read())
{
bfid = dr[0].tostring().trim();
sql = "select Class from batch";
dr = scon.readsql(sql);
if(d.hashrows == true)
{
gridview.datasource = dr;
GridView1.DataBind();
GridView1.Visible = true;
}
在运行模式下如下
我点击时有一个名为Load的按钮在gridview中按钮输出如下
In run mode as follows
I have one button called Load when i click that button the output as follows in gridview
Studid Bfid Rate class
A 1 Good EFA
B 2 Fair MFA
C 3 Excellent COC
我怎么能用csharp。
问候,
Narasiman P.
for that how can i do using csharp.
Regards,
Narasiman P.
推荐答案
只需将你的sql语句更改为
Just change your sql statement to
sql = "Select studid,s.Bfid,Rate,class from student s left outer join Batch b on s.Bfid=b.Bfid";
我已经使用左外连接
以防你拥有没有批记录的学生记录。如果您只想列出具有批记录的学生,请将其更改为内部联接
另请注意,我必须指定select子句中的 s。 Bfid
,因为列Bfid出现在两个表中。只使用Bfid会导致模糊错误。
I''ve used left outer join
in case you have student records that do not have Batch records. If you only want to list students that do have a Batch record then change it to inner join
Also note that I''ve had to specify s.Bfid
in the select clause because the column Bfid appears on both tables. Just using Bfid leads to an ambiguity error.
尝试使用单个查询...
try with single query ...
sql = "Select studid,Bfid,Rate,Class from student,batch";
$ b绑定网格之后的b $ b
after this bind grid
这篇关于当我点击生成按钮输出以在gridview中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!