This is a migrated thread and some comments may be shown as answers.

ListView binding issue

8 Answers 89 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 10 Jul 2010, 08:23 AM
Hi guys!
We've been using Telerik.Web.UI v.2010.1.309.35 in our project, and recently have switched to v.2010.1.519.35 . Since that I've discovered that ListView doesn't seem to process <%%> tags correctly during binding. For instance, here's the EditItemTemplate that I have:
<EditItemTemplate>
 <tr>
  <td style="vertical-align:top">
   <rlt:TextBox ID="txtDurationMonth" runat="server" 
                ValueType="Integer"
                Width="50px" 
                Text='<%#Eval("DurationMonth") %>'
   ></rlt:TextBox>
   <asp:RangeValidator runat="server" 
                ControlToValidate="txtDurationMonth" 
                ErrorMessage="Integer value required" 
                MinimumValue="0" 
                MaximumValue="<%#int.MaxValue %>" 
                Type="Integer" 
                SetFocusOnError="true">
   </asp:RangeValidator>
  </td>
  <td style="vertical-align:top">
   <rlt:LinkButton ID="lbSave" runat="server" 
          CommandName="<%#RadListView.UpdateCommandName%>" CommandArgument='<%#Eval("Id") %>'>Save</rlt:LinkButton>
  </td>
 </tr>
</EditItemTemplate>
When I switch into Edit mode, I started getting an exception that it cannot parse '' (empty string) for MaximumValue of rangevalidator. I removed that validator at all and it switched fine, but CommandName of lbSave was always empty. Also, ListView has DataKeyNames="Id" However, if I try to get an ID in ListView ItemCommand handler like this:

((

RadListViewDataItem)e.ListViewItem).GetDataKeyValue("Id")

I get "index was out of range" exception. So I had to switch back to v.2010.1.309.35.  And now it works as it should, but that version has an issue with RadEditor, which is being stretched in some occasions.
So, is it some bug or do I miss something? Thanx in advance!

 

8 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 12 Jul 2010, 09:01 AM
Hello Andy,

Unfortunately I'm unable to observe the described behavior locally. Therefore can you please provide more details about your scenario and implementation, such as how the control is populated etc.?

Kind regards,
Rosen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Andy
Top achievements
Rank 1
answered on 12 Jul 2010, 10:25 AM
Thanx for reply, Rosen!

We bind datasource in ListView.NeedDataSource event handler, and bind to a generic list:

void lvPriceList_NeedDataSource(object sender, RadListViewNeedDataSourceEventArgs e)
{
  CommonMethods.BindControlToEntity<Price>(lvPriceList, p => p.TypeId == SelectedPriceTypeId);
}

and here's the code for CommonMethods.BindControlToEntity<T> method:
public static void BindControlToEntity<T>(DataBoundControl ctrl, Expression<Func<T, bool>> expression) where T : Entity<RealtorDataContext>, IName
{
 ctrl.DataSource = Box.Box.GetSortedList<T>(expression);
 if (! (ctrl is ListView))
  ctrl.DataBind();
}

Box.Box.GetSortedList<T>(Expression<Func<T, bool>> expression) just returns a generic list of T
0
Rosen
Telerik team
answered on 13 Jul 2010, 01:08 PM
Hello Andy,

Unfortunately I'm still unable to recreate the mentioned  behavior. However I have noticed that in BindControlToEntity method you have a check for ListView instead for RadListView, which should cause exception if this method is called from within NeedDataSource event handler, can you please check?
And just to make sure, you are using the default RadListView implementation, without any modifications, right?

Regards,
Rosen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Andy
Top achievements
Rank 1
answered on 13 Jul 2010, 01:43 PM

Hi Rosen!

ListView class is inherited from RadListView, but it has absolutely no code inside. Did that in case I would need some additional functionality in the future, but had nothing to add so far :) Well, the weird thing about it is that it works fine with an older version of Telerik.Web.UI.dll . I'll try to make a sample project and see if that issue still occures.

Thanx for your attention!

 

 

0
Andy
Top achievements
Rank 1
answered on 14 Jul 2010, 09:53 AM
Looks like we found the problem = it's with InsertItemTemplate actually, not EditItemTemplate.
If we use <%#int.MaxValue%> for example, it renders into empty string. Maybe in the newer version InsertItem doesn't participate in databinding process, thus # doesn't work? Sorry for confusion. Please let me know if you are still unable to reproduce the issue. We have a sample project to illustrate it.
0
Accepted
Rosen
Telerik team
answered on 14 Jul 2010, 03:52 PM
Hello Andy,

Can you please check the latest (Q2 2010) release? This behavior should be addressed with it.

Kind regards,
Rosen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Andy
Top achievements
Rank 1
answered on 22 Jul 2010, 09:14 AM
Hi Rosen!
We have finally re-newed our subscription and got the latest version. Yes, this issue seems to be fixed there.. however we started to get some javascript errors in other places, so had to roll-back again.
0
Neha
Top achievements
Rank 1
answered on 16 Aug 2010, 10:37 AM
Hi,
Try using  link ListView.

Regards
TotalDotnet
Tags
ListView
Asked by
Andy
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Andy
Top achievements
Rank 1
Neha
Top achievements
Rank 1
Share this question
or