tags:

views:

73

answers:

1

Hi. I use Visual Studio 2008, C#, MS SQL Server 2005. I have 2 tables that called "record" and "Estatetypes". I have some records in "record" with their estatetype IDs. I have to list my records in a repeater. When i directly databind to repeater, i normally see record's estatetype IDs. But i want to get estatetype's name that is in "Estatetypes" table. I have a code like below. In this situation, "estatetype" feature must be list but i can only list estatetypeid. How can i get estatetype from "Estatetypes" and databind same repeater?

asp:Repeater ID="Estates" runat="server" OnItemDataBound="Estates_OnItemDataBound">

ItemTemplate>

asp:HiddenField ID="estate" runat="server" Value='<%#DataBinder.Eval(Container.DataItem,"RecID") %>' />

a href='EstateDetail.aspx?ID=<%#DataBinder.Eval(Container.DataItem,"recid") %>' ">

<%#DataBinder.Eval(Container.DataItem,"header") %>

a href='EstateDetail.aspx?ID=<%#DataBinder.Eval(Container.DataItem,"RecID") %>' >

<%#DataBinder.Eval(Container.DataItem,"estatetype") %>

/ItemTemplate>

/asp:repeater>

+2  A: 

you have to apply join to both record table and estatype table like the following:

select Es.recid,Es.othercolumn, Es.estatetype, Es.otherColumn from Estatetypes Es,record rec where Es.ID = rec.EstatypeID

now you have one table that contain all the information from estatype and record now bind it to the gridview

peacmaker
Thanks Body, you are right :)
Mehmet Kaleli