web stats analysis

How to bind repeater from two tables in asp.net?

Bind multiple tables to one repeater.

I have a simple solution:

I have two tables Users & Services and my repeater has fields from the two tables.

First create repeater like this.

<asp:Repeater ID="rpServices" runat="server">
<td><%# Eval("photo_user")%></td>
<td><%# Eval("name_user")%></td>
<td><%# Eval("Service_Name")%></td>
<td><%# Eval("Field_service")%></td>
<td><%# Eval("Cost_service")%></td>

Then Create a method for repeater fill up.

private void RepeaterBind()
string connectionString = "Data Source=sandeepss-PC;Initial Catalog=CodeFirst;User ID=sa; Password=knowdev";
SqlConnection cn = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(@"Select u.photo_user,u.name_user,
s.Cost_service FROM Users as u inner join Services as s on u.userId=s.userId", cn);
IDataReader dr = cmd.ExecuteReader();

DataTable dt = new DataTable();
rpServices.DataSource = dt;


Finally Call this method where you filling repeater control.

For example I am calling it on Page_Load.

protected void Page_Load(object sender, EventArgs e)
            if (!Page.IsPostBack)

How to pass style in html tag in aspx.cs page?

Solution for: how to pass style in html tag in aspx.cs page?

I had got simple solution is below type this line in aspx.cs.

Write the below code into aspx page.

<div runat="server" id="divid">

And write the below code into aspx.cs page.

divid.Attributes.CssStyle.Add("property name","value");

Like below example:


How to add custom dynamic table in wordpress?

Create custom table in wordpress.

Follow below steps:

Step:1-Download custom table plugin by Click here
Step:2-Go to your admin panel.
Step:3-Click on Plugin -> Add New.
Step:4-Upload the custom table plugin.
Step:5-Install and active your plugsin.
Step:6-See in left side menu custom table.
Step:7-Select custom table is like click below image.

Below little description about custom table plugin.

The Admin can very simply create an new Table in the Database. The Table can filled in manually over the WordPress admin menu with new entries.The Plugin will create diffrent Shortcodes this plugin create Shortcodes like [wctable] or [wctable id="3"] to add this Tables to the WordPress sites.

Your plugin has been successfully work.

For more reference Click here

The name ‘UnicodeEncoding’ does not exist in the current context.

The name does not exist in the current context unity.

I have a solution is below:

You just add below namespace:

using System.Text;

How to open and close pop up window in asp.net using javascript?

How to display popup window in ASP.Net?

I try and got the solution is below:

You just copy the below javascript and paste into head tag.

<script language="javascript" type="text/javascript">
var win = null;
function OpenPopUp(mypage, myname, w, h, scroll, pos) {
if (pos == "random") { LeftPosition = (screen.width) ? Math.floor(Math.random() * (screen.width - w)) : 100;

TopPosition = (screen.height) ? Math.floor(Math.random() * ((screen.height - h) - 75)) : 100; }
if (pos == "center") { LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100; TopPosition =

(screen.height) ? (screen.height - h) / 2 : 100; }
else if ((pos != "center" && pos != "random") || pos == null) { LeftPosition = 0; TopPosition = 20 }
settings = 'width=' + w + ',height=' + h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' +

scroll + ',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
win = window.open(mypage, myname, settings);

Then copy the below code and paste into body tag where you want the link to appear.

<a href="http://www.code.top10idea.com"  onclick="OpenPopUp(this.href,'mywin','1050','555','yes','center');return false"

onfocus="this.blur()">Click here to Display pop up window</a>
Above example will open http://www.code.top10idea.com in popup window. But if you want display popup in another page so you just replace your website like below:

<a href="default2.aspx"  onclick="OpenPopUp(this.href,'mywin','1050','555','yes','center');return false"

onfocus="this.blur()">Click here to Display pop up window</a>

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.