web stats analysis

Archive for August 26th, 2013

How can we filter text from array in asp.net?

Search and Filter Array in ASP.Net.

I try and get solution: is like below:

I have an array which return data in size like 3,6,9,12,15.. (multiplication of 3)

Add the below code:

DataTable dt = new DataTable();
string GridData = ViewState["ShowItem"].ToString();
string[] FilterData = GridData.Split('^');

Above array return data like..

FilterData [0] = "Pizza";     (Item)
FilterData [1] = "2$";        (Price)
FilterData [2] = "2";         (Quantity)
FilterData [3] = "Burger";
FilterData [4] = "5$";
FilterData [5] = "1";
FilterData [6] = "Cesa";
FilterData [7] = "7$";
FilterData [8] = "3";

now I want to enter some data as column wise in database like:

Item     Price     uantity     Total(Price*Quantity)

Then add the below loop:

for (int nIndex = 0; nIndex < FilterData.Length; nIndex += 3)
    DataRow drow = dt.NewRow();
    drow["ProductItem"] = FilterData[nIndex];               // Item
    var cost = FilterData[nIndex + 1];                      // Cost
    var qty = FilterData[nIndex + 2];                       // Quantity
    drow["Cost"] = cost;
    drow["Quantity"] = qty;
    double Total =
        Convert.ToDouble(cost.Remove(cost.Length - 1)) *    // remove $
        Convert.ToInt32(qty);                               // Total
    drow["Total"] = Total;

Hope it help you better:

How to upload file in asp.net?

ASP.NET – File Uploading.

Basic syntax

<asp:FileUpload ID= "Uploader" runat = "server" />

Write the below code in HTML Document Default.aspx.

<form id="form1" runat="server">
<h3> Uploading File :</h3>
<br />
<asp:FileUpload ID="FileUpload1" runat="server" />
<br /><br />
<asp:Button ID="btnadd" runat="server"
onclick="btnadd_Click" Text="Add"
Width="85px" />
<br /><br />
<asp:Label ID="lblmessage" runat="server" />

Open Default.aspx.cs file and add following namespace:


After added namespace write the following code into Default.aspx.cs:

protected void btnadd_Click(object sender, EventArgs e)
StringBuilder strbl = new StringBuilder();
if (FileUpload1.HasFile)
strbl.AppendFormat(" Uploading file: {0}",
//saving the file
FileUpload1.SaveAs("<c:\\SaveDirectory>" +
//Showing the file information
sb.AppendFormat("<br/> Save As: {0}",
strbl.AppendFormat("<br/> File type: {0}",
strbl.AppendFormat("<br/> File length: {0}",
strbl.AppendFormat("<br/> File name: {0}",
catch (Exception ex)
strbl.Append("<br/> Error <br/>");
strbl.AppendFormat("Unable to save file <br/> {0}",
lblmessage.Text = strbl.ToString();

Hope it help you better:

How to open PDF files in web brower using asp.net?

Asp.net open PDF file in web browser using C#.

I have a simple solution is like below:

First create one new website and add one of your existing pdf file to your website after that open Default.aspx page and write the following code.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Open PDF File in Web Browser in asp.net</title>
<form id="form1" runat="server">
<asp:Button ID="btnOpen" Text="1st Show PDF In Browser" Font-Bold="true" runat="server" onclick="btnOpen_Click" />
<asp:Button ID="btnpdf" Text="2nd Show PDF In Browser" Font-Bold="true" runat="server" onclick="btnpdf_Click" />

Open Default.aspx.cs file and add following namespace:

using System;

using System.Net;

After added namespace write the following code:

protected void Page_Load(object sender, EventArgs e)
// First Way to show PDF in browser

protected void btnOpen_Click(object sender, EventArgs e)

protected void btnpdf_Click(object sender, EventArgs e)
string path = Server.MapPath("SiteAnalytics.pdf");
WebClient client = new WebClient();
Byte[] buffer = client.DownloadData(path);

if (buffer != null)
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", buffer.Length.ToString());

Hope it help you better:

how to write connection string in web.config file and read from it in asp.net?

How to: Read Connection Strings from the Web.config File?

Look at below connectionstring code:

       <add name="Your Connection string name" connectionstring="data source=server name;
        Database=database name;uid=Database Username;pwd=password;
        multipleactiveresultsets=true;" providername="System.Data.SqlClient" />

For call connection string write the below code:

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings
["Connection string name"].ConnectionString.ToString());

Connection string name means your connection name:

How to search data on dropdown selection in asp.net?

Display the data in gridview based on dropdownlist selected value.

I get simple solution.

Your simple answer is below.

You have to write your gridview binding code over the dropdown_selectedIndexChange event and also set allow Auto Postback property true of dropdown.So, when you select any value from dropdown you will be able to see Gridview with existing bind data.

How to convert Html page to Pdf using asp.net (C#)?

HTML to PDF for using asp.net.

I have simple solution is bellow.

You just use below code and convert HTML to PDF.

protected void Page_Load(object sender, EventArgs e)


ArrayList ar_li = new ArrayList();



BinaryFormatter bnr_f = new BinaryFormatter();

MemoryStream mstrm = new MemoryStream();

bnr_f.Serialize(mstrm, ar_li);

CR_visitor_Pass cr_vi = new CR_visitor_Pass();


//MemoryStream oStream;    // using System.IO

//oStream = (MemoryStream) ar_li;


Response.Buffer = true;

Response.ContentType = "application/pdf";




How to create attractive button step by step?

Use of CSS3 for making attractive button.

Here I try and making a attractive button:

In HTML Document:

<a href="#">Click Here</a>

I create div having a link (Name:Click Here)..Add below css:

border:1px solid black;

I only created a box here inside which I have to create a button.

padding:20px 30px;
border:solid 1px #ec3838;
transition: all 0.1s;
-webkit-box-shadow: 0px 9px 0px #a81515;   /*for opera and safari*/
-moz-box-shadow: 0px 9px 0px #a81515;     /*for mozilla*/
-o-box-shadow: 0px 9px 0px #a81515;      /*for opera*/
-ms-box-shadow: 0px 9px 0px #a81515;    /*for I.E.*/
I set text-decoration to none that’s why link underline is removed. After that, I set color and background-color. Then, I set text-align and padding. The important step here is transition and box-shadow.

CSS3 transitions are effects that let an element gradually change from one style to another.

Add below css:

-webkit-box-shadow: 0px 2px 0px #a81515;
-moz-box-shadow: 0px 2px 0px #a81515;
-o-box-shadow: 0px 2px 0px #a81515;
-ms-box-shadow: 0px 2px 0px #a81515;

Note:-Active selector is use to select and style the active link.A link active when you click on it

This button working is that decrese box-shadow and muve the position slightly down so that appears pressing down

How to refresh a page after file upload?

File upload and page refresh in asp.net.

You can simply by below solution.

You simply add this below FileUp.SaveAs:

‘mypage.aspx’ is the name of current aspx page.You can use responce redirect to refresh the page. If there are querystring variable then follow below.

Response.Redirect(“mypage.aspx” + Request.QueryString.ToString());

How to add arrow in wordpress menu ?

Add arrow on the sub menu with child elements in wordpress.

How can we add arrow on the sub menu with the child elements on the repsonsive theme?

I try and get simple solution:

You just add below script in your css where you want arrow in responsive menu.

.nav-menu li > a:after{

color: #888;


content:  " \25BA";


.nav-menu li > a:hover:after {

color: #444;

content: " \25BA";


.nav-menu li > a:only-child:after {

content: '';


After adding script go to start -> run -> and type character map.

Character map using for choosing different different arrow purpose it’s like click below image.

Choose arrow and get the code of particular arrow here above image I make a round on code. Type this code into your content in script.