Question

I am using repeater in asp.net website, in this repeater i have labels in which i am showing data from database table.

<asp:Label ID="lbl_state" runat="server" Text='<%#Eval("state") %>'></asp:Label>

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.

Was it helpful?

Solution

Change your fetching query to

SELECT R.*, S.name AS statename FROM register R LEFT JOIN state S ON R.state = S.id

and use

<asp:Label ID="lbl_state" runat="server" Text='<%#Eval("statename") %>'></asp:Label>

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top