Tuesday 19 February 2013

Telerik RadGrid Pager error (Invalid postback or callback argument. Event validation is enabled using "" in configuration or <%@ Page EnableEventValidation="true" %> in a page.)

If u got Error like:

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

To Solve this type of error do then following code in page load and bind the radgid

Code Here:
protected void Page_Load(object sender, EventArgs e)
{
  try
  {
    if (!IsPostBack)
    {
      radGrid1.DataSource = dt;
      radGrid1. DataBind ();
    }
  }
  catch (Exception ex)
  {
    Logger.LogError(ex);
  }
}

Saturday 16 February 2013

Telerik RadGrid PageSize Combobox If not working.

If you are facing some problem like
  • When you are changing the the page size in Pagesize combobox. After that the grid not showing the the the page size that you are changed.
  • Then Do the following to solve this issue.
Step1:-
  • First Add a Telerik Rad GridView.

Here is the Source Code for Telerik RadGrid:-




    
      
     
       
        
         
        
       
       
        
          
        
       
       
        
         
        
       
       
        
         
        
       
       
         
          
         
       
    
  



Here is the C# Code:

protected void grdMerg_PageIndexChanged(object sender, GridPageChangedEventArgs e)
{
  RadGrid1.CurrentPageIndex = e.NewPageIndex;
  //Here bind the grid
}

protected void grdMerg_ItemCreated(object sender, GridItemEventArgs e)
{
  if (e.Item is GridPagerItem)
  {
    GridPagerItem pager = (GridPagerItem)e.Item;
    RadComboBox PageSizeComboBox = (RadComboBox)pager.FindControl("PageSizeComboBox");
    PageSizeComboBox.AutoPostBack = true;
    PageSizeComboBox.SelectedIndexChanged += new     RadComboBoxSelectedIndexChangedEventHandler(PageSizeComboBox1_SelectedIndexChanged);
   }
}

void PageSizeComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
  //Here bind the grid
}

Friday 8 February 2013

Telerik RadGrid PageSize ComboBox Change Value

How to Change the Value in RadGrid PageSize ComboBox :
Source Code:

        
            
........
........
........

Default Sort column in telerik RadGrid

How to make a default sort column in Telerik RadGrid

Here is the .cs code


GridSortExpression expression = new GridSortExpression();
expression.FieldName = "EMPNAME";
expression.SortOrder = GridSortOrder.Descending;
RadGrid1.MasterTableView.SortExpressions.AddSortExpression(expression);
RadGrid1.MasterTableView.DataSource=your DataSource;
RadGrid1.MasterTableView.DataBind();

You can do using HTML code inside MasterTable

 
   
       
  

......
......

Saturday 2 February 2013

Telerik RadWindow as modal popup

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Popup.aspx.cs" Inherits="TestProject.Popup" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>



    


    
    
    
Steps:-
  • First copy and paste the above code in your aspx page.
  • Then run the page.
  • Then there is button name as Click.Click this button and you gate the follwing output.
Output: