Friday 21 October 2011

Solution for Pageindex error on datagrid bind

if (DT.Rows.Count > 0)
               {
                   try
                   {
                       DataView dvCompanyName = new DataView(DT);
                       grdProductList.DataSource = dvCompanyName;
                       grdProductList.DataBind();
                   }
                   catch (Exception ex)
                   {
                       if (!(grdProductList.CurrentPageIndex < grdProductList.PageCount))
                       {
                           if (!(grdProductList.PageCount == 0))
                           {
                               grdProductList.CurrentPageIndex = grdProductList.PageCount - 1;
                               grdProductList.DataBind();
                           }
                       }
                       else
                       {
                           grdProductList.DataBind();
                       }
                   }
               }

Wednesday 14 September 2011

Comparing Arrays(Finding Unique Values by comparing arrays)

 string[] Array1 = { "Vinay", "Pradeep", "Manoj", "Nimesh", "Sandy", "Viren", "Suresh" };
 string[] Array2 = { "Vinay", "Pradeep", "Manoj", "Nimesh", "Sandy" };

        foreach (string nextRole in Array1)
        {
            int position = Array.IndexOf(Array2, nextRole);
            if (position < 0) // change it to > if u want common values from both arrays)
            {
                Response.Write(nextRole + "<br/>");
            }
        }

========================

Output:
Viren
Suresh
===============

Monday 6 June 2011

Alertbox from codebehind(C#)

Code:
public void Say(string msg)
    {
        string popupScript;
        popupScript = "<script language='javascript'>alert('" + msg + "');</script>";
        ClientScript.RegisterStartupScript(this.GetType(), "popupScript", popupScript);
    }

Calling:
 Say("Please Select a Subject");



Friday 3 June 2011

Hello world!!

Hi,

Greetings!!!

This is my first post of this blog..I will keep updating the blog with small scale utilities used in day-to-day programming.

Be online..