Tuesday, February 9, 2010

How to control the data in text area using ASP.NET and Java Script


First Create a java script as given below
====================================================
function countDown(control, maxLen, counter, typeName) {
var len = control.value.length;
var txt = control.value;
var span = document.getElementById(counter);
span.style.display = ”;
span.innerHTML = (maxLen – len) + ‘ characters remaining’;
if (len >= (maxLen – 10)) {
span.style.color = ‘red’;
if (len > maxLen) {
control.innerHTML = txt.substring(0, maxLen);
span.innerHTML = (maxLen – control.value.length) + ‘ characters remaining’;
alert(typeName + ‘ text exceeds the maximum allowed!’);
}
} else {
span.style.color = ”;
}
}
Add This Code in The .aspx file of the .net Programms 












Description:
TextBox onpaste=”countDown(this, 450, ‘desc’, ‘Description’);” id=”Description” onkeypress=”countDown(this, 450, ‘desc’, ‘Description’);” Wrap=”true” onkeyup=”countDown(this, 450, ‘desc’, ‘Description’);”
runat=”server” TextMode=”MultiLine”>
450  characters remaining



now Execute and Check…
Thanks

Friday, February 5, 2010

Papulate dataset using Csv file Using C# Class method

How to create CSVReader class


public class CSVReader

  {
     //
     private Stream objStream;
     private StreamReader objReader;
       //add name space System.IO.Stream
     public CSVReader(Stream filestream) : this(filestream, null) { }
      public CSVReader(Stream filestream, Encoding enc)
      {
       this.objStream = filestream;
          //check the Pass Stream whether it is readable or not
        if (!filestream.CanRead)
        {
            return;
           }
         objReader = (enc != null) ? new StreamReader(filestream, enc) : new StreamReader(filestream);

      }

     //parse the Line

       public string[] GetCSVLine()

     {

         string data = objReader.ReadLine();

      if (data == null) return null;

         if (data.Length == 0) return new string[0];

       //System.Collection.Generic

        ArrayList result = new ArrayList();

          //parsing CSV Data

      ParseCSVData(result, data);

         return (string[])result.ToArray(typeof(string));

      }

   

      private void ParseCSVData(ArrayList result, string data)

      {

           int position = -1;

          while (position < data.Length)

               result.Add(ParseCSVField(ref data, ref position));

      }

   

      private string ParseCSVField(ref string data, ref int StartSeperatorPos)

      {

       if (StartSeperatorPos == data.Length - 1)
              {

              StartSeperatorPos++;
                        return "";
                   }
          
                  int fromPos = StartSeperatorPos + 1;
                   if (data[fromPos] == '"')
                            {
                                 int nextSingleQuote = GetSingleQuote(data, fromPos + 1);
                                   int lines = 1;
                                   while (nextSingleQuote == -1)

            {                 data = data + "\n" + objReader.ReadLine();

                 nextSingleQuote = GetSingleQuote(data, fromPos + 1);

                  lines++;

                  if (lines > 20)

                      throw new Exception("lines overflow: " + data);

              }

               StartSeperatorPos = nextSingleQuote + 1;
                                string tempString = data.Substring(fromPos + 1, nextSingleQuote - fromPos - 1);
                                   tempString = tempString.Replace("'", "''");

              return tempString.Replace("\"\"", "\"");
                               }
          
                  int nextComma = data.IndexOf(',', fromPos);
                 if (nextComma == -1)
                             {
                                 StartSeperatorPos = data.Length;
                                  return data.Substring(fromPos);
                             }
                  else
                             {
                                StartSeperatorPos = nextComma;
                                  return data.Substring(fromPos, nextComma - fromPos);
                              }
               }
     
          private int GetSingleQuote(string data, int SFrom)
                  {
                      int i = SFrom - 1;
                       while (++i < data.Length)
                                    if (data[i] == '"')
                                                 
                                   
                 {
                                                        if (i < data.Length - 1 && data[i + 1] == '"')
                                                                         {
                                                                              i++;
                                                                                 continue;
                                                                            }
                                                      else
                                                                          return i;
                                                }
                    return -1;
                }

How To call it inn .CS file

on button clik and papulate this data in Grid view


protected void Button1_Click(object sender, EventArgs e)
    {
        if (FileUpload1.PostedFile.FileName == string.Empty)

         {
                   Label1.Visible = true;
                     return;
                 }
             else
                {
                  //save the file
                    //restrict user to upload other file extenstion
                     string[] FileExt = FileUpload1.FileName.Split('.');
                    string FileEx = FileExt[FileExt.Length - 1];
                    if (FileEx.ToLower() == "xls")
                           {
                              FileUpload1.SaveAs(Server.MapPath("File//" + FileUpload1.FileName));
                               }
                    else
                              {
                                     Label1.Visible = true;
                                     return;
                                }
                }
          //create object for CSVReader and pass the stream
        XLsReader reader = new XLsReader(FileUpload1.PostedFile.InputStream);
            //get the header
             string[] headers = reader.GetXLSine();       
               DataTable dt = new DataTable();
           //add headers
            foreach (string strHeader in headers)
                     dt.Columns.Add(strHeader);
           string[] data;
          while ((data = reader.GetXLSine()) != null)
                  dt.Rows.Add(data);
           //bind gridview
           GridView1.DataSource = dt;
           GridView1.DataBind();
          
    
    }

Thursday, October 29, 2009

is indian cricket team growing

I am a Indian and due to be Indian i have also a emotion and affection for my country.well i was talking about my Team India.Yeah it is preety well now a days in performance but we cant judge it by wining a single match.Every one says that team India is well but I don think so because they don't win matches in big tournaments Like Champions trophy,world cup or even in t20. So then not a real champions or not on the right path of to be champaign.
If India win matches in big tournaments then they will be in progress otherwise not according to me. yeah due to Indian we always hops that we will play very well and win big one.
only becoming no. 1 in ranking is not equal to be champions but to win big one like Champions trophy,world cup is the way to be champions.

Wednesday, October 28, 2009

HOW TO CREATE SQL INPUT STORE PROCEDURE

dear friends if you don know how to create procedure then worry i will give you iddea how to create procedure ........so now learn how to create input store procedure ..
FIRST CRAETE TABLE

CREATE TABLE RAJ(R_ID INT,R_NAME VARCHAR(10));
INSERT INTO RAJ VALUES(1,'ANAND');
INSERT INTO RAJ VALUES(2,'VIKAS');
INSERT INTO RAJ VALUES(1,'VICKY');

/*NOW WE HAV TO CRAETE STORE PROCEDURE*/
CREATE PROC RAJU
(
@R_ID INT,
@R_NAME VARCHAR(10)
)
AS
BEGIN
INSERT INTO RAJ (@R_ID,@R_NAME);
END
EXEC RAJU 1,'ANAND';
NOW YOUR STORE PROCEDURE HAS BEEN CREATED.........

Tuesday, October 9, 2007

Ambani bros world’s richest

$91 billion:Ambani


The Indian stock market boom has made the Ambani brothers arguably the richest in the world if one clubs the fortunes of Mukesh and Anil, which at $91.41 billion is far ahead of even the Walton family of Wal-Mart.
Sons of legendary industrialist Dhirubhai Ambani, who began his career as a petrol station attendant in Yemen and later founded Reliance Industries, Mukesh and Anil split their father’s business empire between them in June 2005. While Mukesh controls shares worth $55.81 billion, Anil owns shares worth $35.6 billion in their respective groups, whose combined worth stands at just over $170 billion. The wealth of the two brothers, as also their group companies, are based on information available on Bombay Stock Exchange (BSE) and the closing price of the group companies on Tuesday.
The net worth of the Walton family, which controls nearly 39% in Wal-Mart, is around $72 billion based on the market capitalisation of the retailer, which is $184.21 billion. In June 2005, when the Reliance empire was split, its market valuation stood at a little over Rs 1,10,000 crore,
which has since shot up to over Rs 6,00,000 crore.
In March, Forbes magazine had ranked Mukesh and Anil Ambani as the 14th and 18th richest persons in the world respectively. Their combined wealth then stood at $38.3 billion, just a little over the $32 billion wealth of steel baron Lakshmi Mittal (fifth richest).
After Tuesday’s surge in the stock market, which saw sensex crossing the 18,000-point milestone with a gain of 789 points, the wealth of the five richest resident Indians too has soared.
The total market cap of firms listed on BSE on Tuesday soared to Rs 54,85,247.44 crore, BSE data shows. The market cap stood at about Rs 51,19,729 crore on September 26, when the sensex hit the 17,000-mark.

Sensex just 1720 points from 20K!


Biggest Single-Day Rise Of 789 Points Helps It Rocket Past 18K


Raging bulls on Dalal Street set many new records today. For one, the BSE sensex turned 18. Call it a coming of age of sorts; the index closed at 18,280, up 789 points for the first time. This was the fastest the sensex has ever moved up in a single day. Second, investors were richer by a record Rs 2.11 lakh crore in just about six hours of trading on Tuesday.
Viewed in percentage terms, the sensex moved up 4.5%. This percentage rise, however, pales when compared with what happened in March 1992. That was when the sensex moved up 13.1% in a single day on the back of a frenzy fuelled by Harshad Mehta. It must also be quickly mentioned that of the five largest gains the sensex has made in a single day, four have happened in 2007.
The day also witnessed FII inflows for 2007 crossing the $15 billion mark with a record $838 million coming in on a single-day.
The main drivers for Tuesday’s rally were not expectations of strong economic and corporate growth that have weaned foreign fund managers into the country. It was political news that the Left parties are not withdrawing support yet to the ruling coalition at the centre. ‘‘Although the meeting of the UPA alliance was only postponed to October 22, everybody in the market is buying as if there is no tommo row,’’ said a top broking house official. FACTORS 1 Buying by foreign funds as the Indian rupee appreciated against the dollar, projections of strong economic growth and expectations of robust corporate earnings 2 Possibilities of immediate mid-term general elections slimmed after Tuesday's meeting of UPA members 3
Strong positive news flows from frontline companies

Morgan Stanley plans to manage Indians’ wealth


Morgan Stanley is unleashing a major drive to tap India’s domestic wealth next year, hiring 100 private bankers in a bid to manage $1 billion in assets by the end of 2010.
The Wall Street bank, which has offshore private banking operations in Singapore and Hong Kong, is making a push into the Indian domestic wealth market where Citigroup and Merrill Lynch already have huge plans.
That will be our first buildout on an onshore private wealth business in Asia,” said Leslie Menkes, a Singapore-based MD for the Wall Street bank’s private wealth management arm, while speaking at the Reuters Wealth Management Summit.

Morgan would be competing against Citigroup and Merrill Lynch as the three US banks aggressively try to tap India’s fast-growing private banking market. India had 100,000 millionaires in 2006, up 21% from a year earlier, according to a Merrill Lynch/Capgemini report.
Merrill said in March it
plans to expand to cover at least 10 Indian cities in the next three years, from five cities now. A senior Citigroup executive said in February that the bank plans to double the number of bankers dealing with wealthy non-resident and resident Indians from about 100, by the end of 2008.
Citi’s Smith Barney broking unit, which handles clients with assets of at least $1 million, plans to expand from one office now to a presence in 12 Indian cities.
Menkes said Morgan Stanley’s focus would be mainly on
rupee-based business targeting wealthy clients who have $5 million in assets. That group makes up 40 percent of India’s 100,000 millionaires.
Internationally it targets clients who have $25 million in assets. “We will open for business in the middle of next year. We will certainly open in Mumbai, Delhi and Calcutta and probably in Bangalore,” he said, adding by the end of 2010 it wants to be in eight locations in India. Menkes said the bank has hired four senior executives from Merrill Lynch. REUTERS