Monday, 20 January 2014

How to Create Random Number using C#

Creating Random Number Using C#
Its very easy to create Random number using C#.
In C#,we have simple class call as Random class.
By using this class , we can automatically generate random numeric numbers.
Example :
public static Random r = new Random();
int number = r.Next();

After doing this ,assign this integer variable (number) to your variable.
It will create 9 digit numeric.
Note: You can generate any random number like String,integer etc.

Monday, 2 December 2013

How to Merge Two Table

Below will give you the solution about, how to merge two tables
Code:
using System;
using System.Data;
using System.Configuration;
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 System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
 SqlConnection con;
 SqlDataAdapter da; 
 DataSet ds1 = new DataSet();
 DataSet ds2 = new DataSet();

 protected void Page_Load(object sender, EventArgs e)
 {
   binddata();
 }

 public void binddata()
 {
   con=new SqlConnection(“Data Source=MCN101; Initial Catalog=MergeTable; Uid=sa; pwd=***”);
   da = new SqlDataAdapter(“Select * from Table1?, con);
   da.Fill(ds1, “Record”);
   da = new SqlDataAdapter(“select * from Table2?, con);
   da.Fill(ds2, “Record”);
   ds1.Merge(ds2);
   GridAllRecord.DataSource = ds1;
   GridAllRecord.DataBind();
 }
}

How to display Telerik RadDatePicker Calendar PopUp Above

For this issue,you have to do two simple steps.These simple two steps are  as follows:--

Step-1:
   First use this JavaScript in your HTML code
JavaScript :

     


Step-2:
After that you have to use this below code in your .cs file(Page_Load event)
RadDatePicker1.DatePopupButton.Attributes.Add("onclick","PopupAbove(event, '" +  RadDatePicker1.ClientID + "');return false;");
Note:-

If you are till facing problem,i mean to say that Calendar popup not showing on top then let me know.Comment please

Telerik RadGrid Pager 508 compliances

Here is the code:
Copy this code and paste it in your RadGrid.

     
       
-------
-------
    

Tuesday, 21 May 2013

Validate Checkbox using Custom Validator

Validate Checkbox using Custom Validator : Here is the Html code:



Here is the .cs Code :
protected void chkSignaturecheck(object source, ServerValidateEventArgs args)
  {
     if (chkSignature.Checked)
     {
       args.IsValid = true;
     }
     else
     {
       args.IsValid = false;
     }
  }
Here is the output

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
}