如何在标签中显示状态名称而不是数字值 [英] How Can I Show A State Name Instead Of Numeric Value In Label
问题描述
我在asp.net网站上使用转发器,在这个转发器中我有标签,我在其中显示数据库表中的数据。
例如: -
< asp:标签ID =lbl_staterunat =serverText ='<%#Eval(state)%>'>
此处状态数据是状态ID,它是数字。
我在数据库1中有两个表。)寄存器2.)状态
当我注册产品时我将状态ID保存在寄存器表中状态。
和状态表我有状态ID和州名。
我从寄存器表中获取数据所以它显示我state id。
但是我想绑定状态名而不是状态id。
使用JOIN从两个表中获取数据。
选择 r。*,s.StateName 来自注册r
INNER JOIN 状态s ON r.StateID = s.StateID
现在你可以使用Statename的。
I am using repeater in asp.net website, in this repeater i have labels in which i am showing data from database table.
eg:-
<asp:Label ID="lbl_state" runat="server" Text='<%#Eval("state") %>'>
here state data is state id which is numeric.
I have two tables in database 1.) register 2.) state
When i register product i save state id in register table for state.
and in state table i have state id and state name.
I am fetching data from register table so it is showing me state id.
But i want to bind state name instead of state id.
Use a JOIN to fetch the data from both tables.
select r.*, s.StateName from Register r INNER JOIN State s ON r.StateID = s.StateID
Now you can use the StateName.
这篇关于如何在标签中显示状态名称而不是数字值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!