Showing posts with label telerik. Show all posts
Showing posts with label telerik. Show all posts

Friday, December 06, 2013

Chronicles on Migration From Entity Framework to Telerik OpenAccess - 1


I have to replace all the EntityDataSources to OpenAccessLinqDataSource's(or the old OpenAccessDataSource)
So this below:
<asp:EntityDataSource runat="server" ID="edsDegree" ConnectionString="name=Entities"  
DefaultContainerName="Entities" EnableFlattening="False"
    EntitySetName="Degrees" Include="College,DegreeType,MajorType"
    EntityTypeFilter="Degree" Where="it.UserID=@UserID">
    <WhereParameters>
        <asp:Parameter Name="UserID" DbType="Int32" />
    </WhereParameters>
</asp:EntityDataSource> 
will become :
<telerik:OpenAccessLinqDataSource runat="server" ID="edsDegree"
    ResourceSetName="Degrees" EntityTypeName="" 
ContextTypeName="DataModel.data"
  Select=" new (PlannedGraduationDate,GraduationDate, College,DegreeType,MajorType)"
    Where="it.UserID=@UserID">
    <WhereParameters>
        <asp:Parameter Name="UserID" DbType="Int32" />
    </WhereParameters>
</telerik:OpenAccessLinqDataSource>
 
 
Neither of the telerik data controls have the "Include" property. So if the EntityDataSource is using it ,
you can Include your related entities as Select="new (ID,Name, ChildEntity )".In the above examples related entities of Degree entity are:
College,DegreeType,MajorType

Monday, December 02, 2013

Telerik OpenAccess include equivalent

  IQueryable<Customer> query = from c in dbContext.Customers.Include(c => c.Orders)
                                       where c.Country == "Germany"
                                       select c;

Thursday, August 01, 2013

RadAsyncUpload too big

<style type="text/css">
 .RadUpload .ruFakeInput
 {
  height: 12px!important;
  width:60px!important;
 }
</style>

Wednesday, June 26, 2013

Fix to "Object must implement IConvertible" error when using objectdatasource withy multivalue parameter under Telerik Reports

If you want to pass multivalue parameters to an objectdatasource you have to make sure the argument type of the objectdatasource's method is object array. You cannot pass a List or array integer or etc.
In the method body convert the object [] to the needed array type  . You can do it this way:
parameter is:
(object[] eventTypes)
   
            int[] eventTypeIDs = eventTypes.Select( Convert.ToInt32).ToArray();

Tuesday, June 25, 2013

Radajaxpanel and RegisterStartupScript

If you want call javascript from server side while using RadAjaxPanel use 
ResponseScripts.Add method. 
 
//Doesnt work  :
   ScriptManager.RegisterStartupScript(this, GetType(), "RefreshDD", 
"RefreshDD();", true); 
 
//Works :
   pnlMain.ResponseScripts.Add("RefreshDD();"); 

Thursday, June 20, 2013

Use Eval to run javascript method inside item template of radgrid

This works :
                <telerik:GridTemplateColumn HeaderText="Edit">
                        <ItemTemplate>
                            <asp:Button runat="server" Text="Edit" AutoPostBack="False"
 OnClientClick='<%# String.Format("openAddContact({0})",Eval("ID"))%> '></asp:Button>

                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
 
This doesn't:
                <telerik:GridTemplateColumn HeaderText="Edit">
                        <ItemTemplate>                        
     <telerik:RadButton ID="Button1" runat="server" Text="Edit" 
 AutoPostBack="False" 
 OnClientClicked='<%# String.Format("openAddContact({0})",Eval("ID"))%> '>
            </telerik:RadButton>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
intersting hah 

Fix to RadNumericTextBox declarative binding error "Specified cast is not valid"

 <telerik:GridTemplateColumn HeaderText="No of  Subscribers">
          <ItemTemplate>
               <%#Eval("SentToCount") %>
          </ItemTemplate>
          <EditItemTemplate>
              <telerik:RadNumericTextBox ID="rnSentCount" runat="server" MaxValue="1000000"
CausesValidation="True"   NumberFormat-DecimalDigits="0" DataType="Int32"  MinValue="1" 
DbValue='<%#Bind("SentToCount") %>'/>
          </EditItemTemplate>
          <InsertItemTemplate>
              <telerik:RadNumericTextBox ID="rnSentCount" runat="server" MaxValue="1000000"
CausesValidation="True" NumberFormat-DecimalDigits="0" DataType="Int32"  MinValue="1"
DbValue='<%#Bind("SentToCount") %>'/>
           </InsertItemTemplate>
 </telerik:GridTemplateColumn>
 
 
  <%#Bind ()%> will not work with Value property so use DbValue instead and it will
 work like a charm. Why intellisense doesnt display DbValue : good question ... to telerik :) 

Tuesday, June 11, 2013

Using empty value in a databound GridDropDownColumn



 In RadGrid if you want to use dropdown box (or the ComboBox) then  there is this  GridDropDownColumn.
And if you want to databind it just set the datasource .
Then the question comes to how to add the empty item to the dropdown
For ex you want 3 items in the combo and "--None--" as the default item in the dropdown box
And if "--None--" is selected it should return null as value.
The EmptyListItemValue  property comes to help, set these 3 properties as below 


EmptyListItemText="None" EmptyListItemValue="" EnableEmptyListItem="True"
 <telerik:GridDropDownColumn HeaderText="TargetOrganisation" 
ListValueField="ID" UniqueName="TargetOrganisationID" 
 DataField="TargetOrganisationID" 
ListTextField="Alias" DataSouceID="edsOrganisation"EmptyListItemText="None" EmptyListItemValue="" EnableEmptyListItem="True">
</telerik:GridDropDownColumn>

RadDatePicker and databinding at design time

RadDatePicker and databinding at design time If you want to bind RadDatePicker at design time , ( like using selectedvalue property of other asp.net controls ) , you can use the DbSelectedDate property:
 <telerik:RadDatePicker runat="server" ID="rdDeterminationDate"   
   
 DbSelectedDate='<%#Bind("DeterminationDate") %>' >  
   
 </telerik:RadDatePicker>  

RadGrid Getting Datakey value of selected row's

GeneralHelper.DeleteContact((int)((GridDataItem)e.Item).GetDataKeyValue("ID"));