Hello!
I have a problem with a listview.
Let me detail a little more:
I have 1 listview, 1 objectdatasource and 2 SQLDatasources..
First the listeview is binded with objectdatasource.
What i want to do after and really don't know how is:
At OnItemDataBound Event, i want to Add, fields( to fill fields actually) from the 2 SQLDatasources.
The 2 SQLDataSources should use as a parameter(ID for the sql query) an item from the listview.
So at OnItemDataBound, i should take the ObjectID pass it to the SQLDataSources, and complete the fields in the listview
This is how the Listview looks like. the Objects datasource brings back: Image/Shortname/Name, one sql datasource brings back addresses and the other brings back contact types.
What i managed to do so far is to get the ID at the OnItemDatabound event. After this i am a little stuck, as i don't know what to do next.
Having to use 1 objectdatasource and 2 sqlDatasources is mandatory.
I have a little update on my solution, but it's still not working, and i don't know how ti fix it.
the aspx code looks like this now:
and in code behind i have the onitemdatabound function:
Now the problem is that all the items in the listview, have the address and the contacts of the last ObjectID.
Ideea anyone?
I have a problem with a listview.
Let me detail a little more:
I have 1 listview, 1 objectdatasource and 2 SQLDatasources..
First the listeview is binded with objectdatasource.
What i want to do after and really don't know how is:
At OnItemDataBound Event, i want to Add, fields( to fill fields actually) from the 2 SQLDatasources.
The 2 SQLDataSources should use as a parameter(ID for the sql query) an item from the listview.
So at OnItemDataBound, i should take the ObjectID pass it to the SQLDataSources, and complete the fields in the listview
<telerik:RadListView ID="RadListView1" runat="server" DataSourceID="ObjectDataSource1" |
ItemPlaceholderID="ListViewContainer" DataKeyNames="ObjectID" AllowPaging="True" OnItemDataBound="Get_rest" > |
<LayoutTemplate> |
<asp:PlaceHolder runat="server" id="ListViewContainer" /> |
</LayoutTemplate> |
<ItemTemplate> |
<fieldset style="float: left; width: 350px; height: 250px;"> |
<legend style="font-weight: normal"><b>Company Name</b>: |
<%# Eval("ShortName")%></legend> |
<div class="details"> |
<div class="photo-container"> |
<telerik:RadBinaryImage runat="server" ID="RadBinaryImage1" DataValue='<%#Eval("WebImage") %>' |
AutoAdjustImageControlSize="false" Width="120px" ToolTip='<%#Eval("Description", "Photo of {0}") %>' |
AlternateText='<%#Eval("Description", "Photo of {0}") %>' /> |
</div> |
<div class="data-container"> |
<ul> |
<li> |
<label> |
Short name</label> |
<%# Eval("Name")%> |
</li> |
<li> |
<label> |
City:</label> |
<%#Eval("City")%> |
</li> |
<li> |
<label> |
ZIP:</label> |
<%# Eval("ZIP")%> |
</li> |
<li> |
<label> |
SPR:</label> |
<%#Eval("SPR")%> |
</li> |
<li> |
<label> |
Country:</label> |
<%#Eval("NationID")%> |
</li> |
<li> |
<label> |
Telephone:</label> |
<%# Eval("Telephone")%> |
</li> |
<li> |
<label> |
Mobile:</label> |
<%# Eval("Mobile")%> |
</li> |
<li> |
<label> |
Fax:</label> |
<%# Eval("Fax")%> |
</li> |
<li> |
<label> |
E-mail:</label> |
<%# Eval("Email")%> |
</li> |
<li style="display:none;"> |
<label id="ObjID_test" runat="server" style="display:none;"> |
<%# Eval("ObjectID")%> </label> |
</li> |
</ul> |
</div> |
</div> |
</fieldset> |
</ItemTemplate> |
</telerik:RadListView> |
What i managed to do so far is to get the ID at the OnItemDatabound event. After this i am a little stuck, as i don't know what to do next.
Having to use 1 objectdatasource and 2 sqlDatasources is mandatory.
I have a little update on my solution, but it's still not working, and i don't know how ti fix it.
the aspx code looks like this now:
<telerik:RadListView ID="RadListView1" runat="server" DataSourceID="ObjectDataSource1" |
ItemPlaceholderID="ListViewContainer" DataKeyNames="ObjectID" AllowPaging="True" OnItemDataBound="Get_rest" > |
<LayoutTemplate> |
<asp:PlaceHolder runat="server" id="ListViewContainer" /> |
</LayoutTemplate> |
<ItemTemplate> |
<fieldset style="float: left; width: 350px; height: 250px;"> |
<legend style="font-weight: normal"><b>Company Name</b>: |
<%# Eval("ShortName")%></legend> |
<div class="details"> |
<div class="photo-container"> |
<telerik:RadBinaryImage runat="server" ID="RadBinaryImage1" DataValue='<%#Eval("WebImage") %>' |
AutoAdjustImageControlSize="false" Width="120px" ToolTip='<%#Eval("Description", "Photo of {0}") %>' |
AlternateText='<%#Eval("Description", "Photo of {0}") %>' /> |
</div> |
<div class="data-container"> |
<ul> |
<li> |
<label> |
Short name:</label> |
<%# Eval("Name")%> |
</li> |
<telerik:RadListView ID="RadListView2" runat="server" DataSourceID="SqlDataSource1" |
ItemPlaceholderID="ListViewContainer" AllowPaging="True" > |
<LayoutTemplate> |
<asp:PlaceHolder runat="server" id="ListViewContainer" /> |
</LayoutTemplate> |
<ItemTemplate> |
<%-- <fieldset>--%> |
<li> |
<label> |
City:</label> |
<%#Eval("City")%> |
</li> |
<li> |
<label> |
ZIP:</label> |
<%# Eval("ZIP")%> |
</li> |
<li> |
<label> |
SPR:</label> |
<%#Eval("SPR")%> |
</li> |
<li> |
<label> |
Country:</label> |
<%#Eval("NationID")%> |
</li> |
<%-- </fieldset>--%> |
</ItemTemplate> |
</telerik:RadListView> |
<telerik:RadListView ID="RadListView3" runat="server" DataSourceID="SqlDataSource2" |
ItemPlaceholderID="ListViewContainer" AllowPaging="True" > |
<LayoutTemplate> |
<asp:PlaceHolder runat="server" id="ListViewContainer" /> |
</LayoutTemplate> |
<ItemTemplate> |
<%-- <fieldset>--%> |
<li> |
<label> |
Phone:</label> |
<%# Eval("Telephone")%> |
</li> |
<li> |
<label> |
Mobile:</label> |
<%# Eval("Mobile")%> |
</li> |
<li> |
<label> |
FAX:</label> |
<%# Eval("FAX")%> |
</li> |
<li> |
<label> |
E-mail:</label> |
<%# Eval("Email")%> |
</li> |
<%-- </fieldset>--%> |
</ItemTemplate> |
</telerik:RadListView> |
</ul> |
</div> |
</div> |
</fieldset> |
</ItemTemplate> |
</telerik:RadListView> |
and in code behind i have the onitemdatabound function:
Protected Sub Get_rest(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadListViewItemEventArgs) Handles RadListView1.ItemDataBound |
Dim ObjID As New Integer |
'Dim RadListColumn As New Telerik.Web.UI.RadListViewDataItemCollection |
Dim item = TryCast(e.Item, RadListViewDataItem) |
If item IsNot Nothing Then |
Dim value = CInt(DataBinder.Eval(item.DataItem, "ObjectID")) |
ObjID = value |
End If |
SqlDataSource1.SelectParameters("ObjectID").DefaultValue = ObjID |
SqlDataSource2.SelectParameters("ObjectID").DefaultValue = ObjID |
End Sub |
Now the problem is that all the items in the listview, have the address and the contacts of the last ObjectID.
Ideea anyone?