Showing posts with label radgrid. Show all posts
Showing posts with label radgrid. Show all posts

Tuesday, June 25, 2013

RadGrid download attachment doesnt work inside Ajax panel

If your download button inside the RadGrid doesnt work if in an ajax panel:
 All you have to do is below( "btnDownload" is the id of the control
 which causes the download):
 
       function RequestStart(sender, args) {
            if (args.get_eventTarget().indexOf("btnDownload") >= 0) {
                args.set_enableAjax(false);
            }
        }
 
<telerik:RadAjaxPanel runat="server" LoadingPanelID="pnlLoading" 
ID="pnlMain" ClientEvents-OnRequestStart="RequestStart">
 

  <telerik:GridTemplateColumn HeaderText="Business Card" >
      <ItemTemplate>
    <asp:LinkButton runat="server" ID="btnDownload" Text="Download" 
CommandName="Download" CommandArgument='<%#Eval("ID") %>'    >
    </asp:LinkButton>
       </ItemTemplate>
 </telerik:GridTemplateColumn>

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>

RadGrid Getting Datakey value of selected row's

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