Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
104 views
Dear Telerik Team

Could you please suggest me how to do filtering in radgrid for a date colum.

i want to filter the date on dd/mm/yyyy.

Please find the below code.

Thanks and Regards
Kishore

aspx source

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CustomerDetails.aspx.cs"
    Inherits="Presentation_Global_CutomerDetails" %>

<%@ Register Assembly="RadAjax.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="radG" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Anand Motors</title>
    <link rel="stylesheet" href="../../Presentation/Global/Style/PMSStyle.css" type="text/css" />
    <style type="text/css">
    .radgrid table.ragrid  tr  td
{
     padding: 0  !important;
     font-size: 25pt;
     font-family: verdana;
}
    </style>
</head>
<body style="margin-left: auto;">
    <form id="form1" runat="server">
        <radG:RadScriptManager ID="ScriptManager" runat="server">
        </radG:RadScriptManager>
        <radG:RadAjaxManager ID="RadAjaxManager2" runat="server">
            <AjaxSettings>
                <radG:AjaxSetting AjaxControlID="RadGrid2">
                    <UpdatedControls>
                        <radG:AjaxUpdatedControl ControlID="RadGrid2" />
                    </UpdatedControls>
                </radG:AjaxSetting>
            </AjaxSettings>
        </radG:RadAjaxManager>
        <radG:RadCodeBlock ID="RadCodeBlock1" runat="server">

            <script language="javascript" type="text/javascript">
           
                function ShowMsg()
                {
                    var sMsg = '';
                    if (sMsg != '')
                        alert(sMsg);
                }
            </script>

        </radG:RadCodeBlock>
        <table cellpadding="1" cellspacing="0" b width="100%" border="0">
            <tr>
                <td align="center" style="width: 100%">
                    <radG:RadGrid ID="RadGrid1" runat="server" GridLines="None" AutoGenerateColumns="False"
                        Skin="Black" Width="100%" AllowPaging="True" PageSize="20" AllowFilteringByColumn="True"
                        AllowSorting="true" OnPreRender="RadGrid1_PreRender" OnItemDataBound="RadGrid1_ItemDataBound1"
                        OnNeedDataSource="RadGrid1_NeedDataSource" OnItemCommand="RadGrid1_ItemDataBound">
                        <MasterTableView CommandItemDisplay="Bottom" Font-Size="Small" Font-Names="Tahoma"
                            DataKeyNames="AgreementId">
                            <FilterItemStyle HorizontalAlign="left" />
                            <HeaderStyle Font-Names="Tahoma" />
                            <HeaderStyle Font-Size="XX-Large" />
                            <ItemStyle BackColor="#000000" Height="20px" />
                            <CommandItemStyle HorizontalAlign="Left" />
                            <Columns>
                                <radG:GridBoundColumn Display="True" ShowFilterIcon="False" UniqueName="" HeaderText="Cust Name"
                                    DataField="CustomerName" CurrentFilterFunction="contains" AutoPostBackOnFilter="true">
                                    <HeaderStyle HorizontalAlign="left" />
                                    <ItemStyle Width="300px" />
                                </radG:GridBoundColumn>
                                <radG:GridBoundColumn Display="false" ShowFilterIcon="False" UniqueName="AgreementId"
                                    HeaderText="Agmt ID" DataField="AgreementId" CurrentFilterFunction="contains"
                                    AutoPostBackOnFilter="true">
                                    <HeaderStyle HorizontalAlign="left" />
                                    <ItemStyle Width="30px" />
                                </radG:GridBoundColumn>
                                <radG:GridBoundColumn Display="True" ShowFilterIcon="False" UniqueName="AgreementNumber"
                                    HeaderText="Agmt Num" DataField="AgreementNumber" CurrentFilterFunction="contains"
                                    AutoPostBackOnFilter="true">
                                    <HeaderStyle HorizontalAlign="left" />
                                    <ItemStyle Width="30px" />
                                </radG:GridBoundColumn>
                                <radG:GridDateTimeColumn PickerType="DatePicker" EditFormColumnIndex="0" DataField="AgreementDate"
                                    HeaderText="Agmt Date" SortExpression="AgreementDate" UniqueName="AgreementDate"
                                    AllowFiltering="false" DataFormatString="{0:dd-MM-yyyy}">
                                </radG:GridDateTimeColumn>
                               
                                <radG:GridBoundColumn Display="True" ShowFilterIcon="False" UniqueName="VehicleName"
                                    HeaderText="Vehicle" DataField="VehicleName" CurrentFilterFunction="contains"
                                    AutoPostBackOnFilter="true">
                                    <HeaderStyle HorizontalAlign="left" />
                                    <ItemStyle Width="80px" />
                                </radG:GridBoundColumn>
                                <radG:GridBoundColumn Display="True" ShowFilterIcon="False" UniqueName="FinanceAmount"
                                    HeaderText="F Amount" DataField="FinanceAmount" CurrentFilterFunction="contains"
                                    AutoPostBackOnFilter="true">
                                    <HeaderStyle HorizontalAlign="left" />
                                    <ItemStyle Width="30px" />
                                </radG:GridBoundColumn>
                                <radG:GridBoundColumn Display="True" ShowFilterIcon="False" UniqueName="CustomerMobilePhone"
                                    HeaderText="Mobile" DataField="CustomerMobilePhone" CurrentFilterFunction="contains"
                                    AutoPostBackOnFilter="true">
                                    <HeaderStyle HorizontalAlign="left" />
                                    <ItemStyle Width="30px" />
                                </radG:GridBoundColumn>
                                <radG:GridBoundColumn Display="True" ShowFilterIcon="False" UniqueName="CustomerOfficePhone1"
                                    HeaderText="Office" DataField="CustomerOfficePhone1" CurrentFilterFunction="contains"
                                    AutoPostBackOnFilter="true">
                                    <HeaderStyle HorizontalAlign="left" />
                                    <ItemStyle Width="30px" />
                                </radG:GridBoundColumn>
                                <radG:GridBoundColumn Display="True" ShowFilterIcon="False" UniqueName="ResidencePhone1"
                                    HeaderText="Res" DataField="ResidencePhone1" CurrentFilterFunction="contains"
                                    AutoPostBackOnFilter="true">
                                    <HeaderStyle HorizontalAlign="left" />
                                    <ItemStyle Width="30px" />
                                </radG:GridBoundColumn>
                                <radG:GridTemplateColumn  HeaderStyle-Width="20px" AllowFiltering="False" UniqueName="editHyperlink">
                                    <ItemTemplate>
                                        <tt class="bodytxt">
                                            <asp:ImageButton ID="btnedit" AlternateText="Edit" ImageUrl="../../Presentation/Global/Images/toolbar/edit.gif"
                                                runat="server" />
                                    </ItemTemplate>
                                    <ItemStyle Width="20px" />
                                </radG:GridTemplateColumn>
                                <radG:GridTemplateColumn HeaderStyle-Width="20px" AllowFiltering="False" UniqueName="editHyperlink">
                                    <ItemTemplate>
                                        <tt class="bodytxt">
                                            <asp:ImageButton ID="btnDelete" CommandName="Delete" AlternateText="Delete" ImageUrl="../../Presentation/Global/Images/toolbar/Delete.gif"
                                                runat="server" />
                                    </ItemTemplate>
                                    <ItemStyle Width="20px" />
                                </radG:GridTemplateColumn>
                            </Columns>
                            <CommandItemTemplate>
                                <div>
                                    <asp:Image ID="Image1" ImageUrl="../../Presentation/Global/Images/toolbar/AddRecord.gif"
                                        runat="Server" />
                                    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Presentation/Customer/AddEditCustomer.aspx"
                                        Font-Underline="true">Add New Customer</asp:HyperLink>
                                </div>
                            </CommandItemTemplate>
                        </MasterTableView>
                        <ClientSettings EnableRowHoverStyle="true" AllowColumnsReorder="true" ReorderColumnsOnClient="true">
                            <Resizing AllowRowResize="False" EnableRealTimeResize="True" ResizeGridOnColumnResize="True"
                                AllowColumnResize="True"></Resizing>
                        </ClientSettings>
                    </radG:RadGrid>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

aspx.cs code behind

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;

public partial class Presentation_Global_CutomerDetails : System.Web.UI.Page
{
    DataTable dtCustInfo;
    MyWebsite.BusinessRule.CustomerInfo custInfo;
    public string sMsg = null;
    protected void Page_Load(object sender, EventArgs e)
    {

        sMsg = Request.QueryString["msg"];
       
    }
    protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {

        custInfo = new MyWebsite.BusinessRule.CustomerInfo();
        if (custInfo.getCustomerInfo(out dtCustInfo) != null)
        {
            this.RadGrid1.DataSource = dtCustInfo;
         
        }
    }
    protected void RadGrid1_PreRender(object sender, System.EventArgs e)
    {
        if (!this.IsPostBack)
        {

            //RadGrid1.ClientSettings.ActiveRowData = String.Format("{0},{1}", RadGrid1.MasterTableView.ClientID, RadGrid1.Items[0].RowIndex);

            this.RadGrid1.MasterTableView.Rebind();
        }
    }
    protected void RadGrid1_ItemDataBound1(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
   
    }

    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridCommandEventArgs e)
    {
        if (e.Item is GridDataItem && e.CommandName != "Delete")
        {
            GridDataItem dataItem = (GridDataItem)e.Item;
            ImageButton btn = (ImageButton)dataItem["editHyperlink"].FindControl("btnedit");
            Response.Redirect("../Customer/AddEditCustomer.aspx?AgId=" + dataItem["AgreementId"].Text);
        }
        else if (e.Item is GridDataItem && e.CommandName == "Delete")
        {
            GridDataItem dataItem = (GridDataItem)e.Item;
            string agreementId= dataItem["AgreementId"].Text;
            custInfo = new MyWebsite.BusinessRule.CustomerInfo();
            custInfo.CustId = agreementId.Trim();
            custInfo.deleteCustomerInfo();
            string nothing = agreementId;
        }
    }
}

Pavlina
Telerik team
 answered on 07 Sep 2010
1 answer
156 views
I'm using a radwindow to drill into a category, showing all of the transactions behind it.  This data is in a radGrid control on the page.

The same page displays data for multiple details and binds the columns at runtime.  The code below is used to open the window and automatically resize it (hopefully) after the data has loaded into the grid.  I've run into two problems autosizing the page based off the grid contents. 

1)  The timeout value is too long for fast computers and too short for slow computers.  Is there an easy way to resize the window reliably AFTER the data has been bound to the grid?

2) When displaying the filter options for the grid columns, the filter types (lessthan, equal, etc) occasionally extend beyond the window boundaries.  Is there a way to ensure that the filter types fit within the window area (even at the expense of limiting the filtering options somewhat)?

openWindow: function(URL, title, modal) {
    var oWnd = $find('portalWindow');
    oWnd.SetUrl(URL);
    oWnd.set_title(title);
    oWnd.Show();
    setTimeout(function() { GetRadWindowManager().GetActiveWindow().autoSize(true); }, 300);
 
    oWnd.center();
    oWnd.set_modal(modal);
    oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Resize);
    oWnd.set_visibleStatusbar(false);


Svetlina Anati
Telerik team
 answered on 07 Sep 2010
1 answer
289 views
Before clicking on filter button i click on export excel button because of no data in telerik radgrid  it generate error
 
RadGrid must be databound before exporting

Try
            gvDomainRegDetail.ExportSettings.FileName = "FileName"
            gvDomainRegDetail.ExportSettings.ExportOnlyData = True
            gvDomainRegDetail.ExportSettings.IgnorePaging = True
            gvDomainRegDetail.ExportSettings.OpenInNewWindow = True
            'gvDomainRegDetail.ExportSettings.Excel.Format = Telerik.Web.UI.GridExcelExportFormat.ExcelML
            gvDomainRegDetail.MasterTableView.ExportToExcel()

        Catch ex As Exception
            Msg_Error(Master, "Error: " & ex.Message)
        End Try


How to fix this error.please any body have idea 
Pavlina
Telerik team
 answered on 07 Sep 2010
1 answer
182 views
hello.

this is my scenario.

i have a web service that brings some products, each product have a name, price, description and image in blob format.

so i'm getting this blob as string and i'm making Convert.FromBase64String(base64String) that return a byte[].

so far so goo, i think!

so, next i fill the property DataValue whit the byte array.

this binaryimage is inside one template of datalist.

but then when i'm trying to render the page e receive a error page with this exception:


Parameter is not valid.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: Parameter is not valid.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[ArgumentException: Parameter is not valid.]
   System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData) +1144615
   System.Drawing.Image.FromStream(Stream stream) +8
   Telerik.Web.UI.ImageFilterHelper.CreateImgFromBytes(Byte[] image) +99

[ArgumentException: The provided binary data may not be valid image or may contains unknown header]
   Telerik.Web.UI.ImageFilterHelper.CreateImgFromBytes(Byte[] image) +173
   Telerik.Web.UI.RadBinaryImage.AutoAdjustImageElementSize(Byte[] dataValue) +50
   Telerik.Web.UI.RadBinaryImage.ProcessImageData() +191
   Telerik.Web.UI.RadBinaryImage.OnPreRender(EventArgs e) +41
   System.Web.UI.Control.PreRenderRecursiveInternal() +103
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496


Hope someone can help. 


best regards
Veli
Telerik team
 answered on 07 Sep 2010
2 answers
163 views

I want to bind telerik Grid to collection loaded in session, I want to enable AllowAutomatic Insert, delete, edit, and modify the datacollection in session.

This grid will be located in a form, so I would like not to trigger validation when I am inserting or editing rows...

Can this be done in an easy fast way...

Thank you
Princy
Top achievements
Rank 2
 answered on 07 Sep 2010
3 answers
151 views
Hi,

I have enabled sorting for header text click and an sorting image provided by RADGrid by default. My application works fine when sorting with header text, please see the image below
http://img44.imageshack.us/img44/2047/phmsappcrash.png

When I click the hyperlink of the sorting image, I get the error below:

http://img535.imageshack.us/img535/7519/phmsappcrasherror.png

Solution will be fine, if there is anyway to disable the hyperlink on sorting image.

With regards,
Munim
Pavel
Telerik team
 answered on 07 Sep 2010
4 answers
120 views
Hi,
I am having web.sitemap file. Now i am creating RadTabs using SiteMapDataSource. My tabs are in one line and some tabs contain child tabs. But here i am facing some problem like
1) As i can't create web.sitemap without root node, i have added root in site map. Because of that  through DataBind() tabs get create with root node and below that all my tabs. But i don't want that root node. When i tried to remove root node it removes all tab below it.

2)When i click on tab it will  not showing child tabs.

I am using Asp.Net Ajax website
please help me..

Regards,
Sagar
Yana
Telerik team
 answered on 07 Sep 2010
1 answer
119 views
Unfortunatly i'm having a very hard time reproducing this problem, but thought i'd post anyway.  For some reason some of our users running IE8 some on windows 7 have an issue with a treeview loading completely disabled and unclickable.

The treeview doesnt have any operations performed on it, and is sitting in an update panel of a content place holder of a master page.  I load it from our database on the server side, the data shows correctly but the treeview is totally un usable.  The only javascript error i've seen is one possibly relating to a radEditor that was invisible at load and in a different update panel.  I'm basing that solely on the line number in the error.  I've since fixed that error, assuming the line number was correct.

I realize it isnt much information to go on, but maybe its a known issue or someone will see this and have some more info.  I'll post more info as i get it if it happens again.

Thanks for any help or information someone can provide.

John
Yana
Telerik team
 answered on 07 Sep 2010
1 answer
92 views
Hello sir,

I am using the RadRotator and when i m performing the event OnItemClick to view the bigger image then rotator resets the source. so it shows the first image.It doesnt preserve the clicked item on the rotator.    

Thanx,
KeeM
Shinu
Top achievements
Rank 2
 answered on 07 Sep 2010
2 answers
97 views
hi
i use these code for bind radgrid
but just first level bind
both of datasource is full
please help to me
protected void Button1_Click(object sender, EventArgs e)
        {
  
            RadGrid RadGrid1 = new RadGrid();
            RadGrid1.ID = "RadGrid1";
            RadGrid1.DataSource = ResultSearch();
            RadGrid1.MasterTableView.DataKeyNames = new string[] { "ShareHolderID" };
            RadGrid1.Width = Unit.Percentage(98);
            RadGrid1.PageSize = 3;
            RadGrid1.AllowPaging = true;
            RadGrid1.AllowSorting = true;
            RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
            RadGrid1.AutoGenerateColumns = false;
            RadGrid1.ShowStatusBar = true;
            RadGrid1.MasterTableView.ExpandCollapseColumn.Visible = true;
            RadGrid1.MasterTableView.PageSize = 3;
            GridBoundColumn boundColumn;
            boundColumn = new GridBoundColumn();
            boundColumn.DataField = "ShareHolderID";
            boundColumn.HeaderText = "ShareHolderID";
            RadGrid1.MasterTableView.Columns.Add(boundColumn);
            boundColumn = new GridBoundColumn();
            boundColumn.DataField = "FirstName";
            boundColumn.HeaderText = "FirstName";
            RadGrid1.MasterTableView.Columns.Add(boundColumn);
            IQueryable<CDSStockDataAccess.tS002ShareHoldersInfo> shareholderinfo = CDSStockLogic.BusinessObjects.UI.ShareHolderInfo.RetrieveShareHolder("2");
            GridTableView tableViewOrders = new GridTableView(RadGrid1);
            tableViewOrders.DataSource = shareholderinfo;
            tableViewOrders.Width = Unit.Percentage(100);
            tableViewOrders.DataKeyNames = new string[] { "_ShareHolderInfoID" };
            GridRelationFields relationFields = new GridRelationFields();
            relationFields.MasterKeyField = "ShareHolderInfoID";
            relationFields.DetailKeyField = "ShareHolderInfoID";
            tableViewOrders.ParentTableRelation.Add(relationFields);
            RadGrid1.MasterTableView.DetailTables.Add(tableViewOrders);
            boundColumn = new GridBoundColumn();
            boundColumn.DataField = "ShareHolderInfoID";
            boundColumn.HeaderText = "ShareHolderInfoID";
            tableViewOrders.Columns.Add(boundColumn);
            boundColumn = new GridBoundColumn();
            boundColumn.DataField = "Address";
            boundColumn.HeaderText = "Address";
            tableViewOrders.Columns.Add(boundColumn);
            this.PlaceHolder1.Controls.Add(RadGrid1);
            RadGrid Grid1 = (RadGrid)PlaceHolder1.FindControl("RadGrid1");
            RadGrid1.MasterTableView.Items[0].Expanded = true;
            Grid1.SelectedIndexes.Add(1, 0);
        }
niloofar
Top achievements
Rank 1
 answered on 07 Sep 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?