比如 有个 客户表 Tab_Customer 字段 :
客户编号 客户名称 客户类型
CusId CusName TypeId但是客户类型是在 Tab_Type表中的
类型编号 类型名称
TypeId TypeName我要查询出客户表的所有数据显示在gridview中 但是 客户类型要显示 TypeId 在 类型表中对应的类型名称应该怎么做 大侠指点!!!
客户编号 客户名称 客户类型
CusId CusName TypeId但是客户类型是在 Tab_Type表中的
类型编号 类型名称
TypeId TypeName我要查询出客户表的所有数据显示在gridview中 但是 客户类型要显示 TypeId 在 类型表中对应的类型名称应该怎么做 大侠指点!!!
from Tab_Customer a inner join Tab_Type b on a.TypeId=b.TypeId
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码)
http://feiyun0112.cnblogs.com/
on a.TypeId=b.TypeId
后台
public string getkind(int kind)
{
if (kind == 0)
{ return "男"; }
if (kind == 1)
{ return "女"; }
return null;
}前台<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# getkind(Convert.ToInt32(DataBinder.Eval(Container.DataItem,"User_Sex"))) %>'></asp:Label>
<%-- '<%# Bind("User_Sex") %>'--%>
</ItemTemplate>这是个性别的例子 道理一样
改下就能用
CusId CusName TypeId IndusId但是客户类型是在 Tab_Type表中的
类型编号 类型名称
TypeId TypeName Tab_Industry
行业编号 行业名称
IndusId IndusName这样调用2个表中间怎样连接??应该怎么做 大侠指点!!!
GridView中增加Combobox类型的列colType(客户类型)
设置
colType.DataPorpertyName = "TypeId";
colType.DataSource = dtType;
colType.DisplayMember = "TypeName";
colType.ValueMember = "TypeId";
那个行业的也这么干
这样做可以直接使用ComboBox进行数据更新
SELECT
A.CusId,
A.CusName,
B.TypeName
FROM
Tab_Customer A
LEFT JOIN
Tab_Type B
ON
A.TypeId = B.TypeId