Click here to Skip to main content
15,910,661 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have two tables

ID Name ImageUrl And ID Name CheckInTime CheckOutTime

I have a listView to which I have bind the the Name and ImageUrl and Working well. So for Now I want to Select data from Second table I want to select CheckInTime and CheckOutTime but as I only have datasouce selected of the first table to display Image from database from ImageUrl.

So what could be suggested for me that could I do It though Query Or some thing else

I have following code
C#
<asp:ListView ID="ListView1" runat="server" DataSourceID="LinqDataSource1" ItemPlaceholderID="ContentID">
       
        <LayoutTemplate>
            <table cellpadding="0" cellspacing="0" border="0">
                
                <tbody  runat="server" id="ContentID">
                </tbody>
               
            </table>
        </LayoutTemplate>
        <ItemTemplate>
            <tr>
                <td width="100px" align="center">
                    <asp:ImageButton AlternateText="ALi" ID="Imgbtn1" runat="server" ImageUrl='<%# Bind("ImageUrl") %>'
                        Width="75px" CommandName="Myselect1" CommandArgument='<%# Bind("Name") %>' OnCommand="ImageButton_Command" />
                         
                        <br />

                         <%# Eval("Name") %> <br /> 
                       
                </td> 
                  
              <%-- <%# Eval("CheckInTime")%> - <%# Eval("CheckOutTime")%> --%>
                         <asp:Label ID="lbl1" runat="server" /> 
                         <asp:Label ID="lbl2" runat="server" />
            </tr>
        </ItemTemplate>
    </asp:ListView>
    <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="Attempt1.DataClasses2DataContext"
        EntityTypeName="" OrderBy="ID" Select="new (ID, Name, ImageUrl)" TableName="CheckInCheckOut1s">
    </asp:LinqDataSource>
</asp:Content>


Here In this code I have commented out he checkinTime and CheckOutTime beacuse it arises an Exception

DataBinding:'Dynamic class1' Does not contain a definition of CheckInTime

Please suugest me How could I get out of it

Regards

Ali
Posted

1 solution

Create a view on the database which contains ID Name ImageUrl And CheckInTime CheckOutTime. Use that view as the datasource.
 
Share this answer
 
Comments
M Ali Qadir 30-Apr-12 14:01pm    
I have Already Tried This thing but I want to do it with two Tables, Do you have any other solution to it.I also tried to Inner Join these two Tables but I don't have exact Idea about it.

Ali

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900