Click here to Skip to main content
15,910,661 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys

I want to use the same datasource that I use for my Repater control for my Detailsview control. My Detailsview is inside my Repeater control but I only want use certain columns for my detailsview. My datasource is created at Page_Init

Here is some code for my Repeater:
XML
<asp:Repeater ID="Repeater1" runat="server"  DataSourceID="SchemeDataSource1">
                        <ItemTemplate>
                            <table>
                                <tr style="border: 2px solid #000000;">
                                    <td>
                                        PRENO
                                        <asp:Label ID="lblPreno" runat="server" Text='<%# Bind("PRENR") %>'></asp:Label>
                                        MONTHLY PREMIUM
                                        <asp:Label ID="lblPremium" runat="server" Text='<%# Bind("PREMIUM") %>'></asp:Label>
                                    </td>
                                </tr>

Any help would be appreciated.
Posted
Comments
graciax8 25-Jul-12 5:16am    
then select only the columns in the datasource that you want to show in the details view. what have you done so far? show your code.
Gericke Hoeksema 25-Jul-12 5:32am    
This is how my Detailsview look like but it doesnt work, it show everything including the item i have added, i just want the items that i add to show in my detailsview. in my datasource is a view that i work with through out my project so i just want certain columns in my detailsview.
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" DataSourceID="SchemeDataSource1">
<fields>
<asp:TemplateField>
<itemtemplate>
BROKER
<asp:Label runat="server" Text='<%# Bind("PREMIUM_BROKER_AMOUNT") %>'>




1 solution

I could not solved it as I was suppose to but what I did was I just use the Repater ItemDataBound event to load my gridview and according to my data in the Repeater I used for parameters for my detailsview so that my data would much up.

Here is some code:

VB
Private Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Dim strPreno As String = DirectCast(e.Item.FindControl("lblPreno"), Label).Text

Dim dv As DetailsView = DirectCast(e.Item.FindControl("dvEarner"), DetailsView)
dv.DataSource = fnLoadPremiums(strPreno)
dv.DataBind()
End If
End Sub
 
Share this answer
 

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