web stats analysis

Error: The name ‘CommandType’ does not exist in the current context.

Error: The name ‘SqlDbType’ does not exist in the current context.

Add following namespace

using System.Data;

How to change date format in c# asp .net?

Below asp.net date format example:


string format = "dd/MM/yyyy";

string date = Convert.ToDateTime("2013-09-05 09:34:43").ToString(format);

Response.Write(date.ToString());

How to make marquee in asp.net?

How to scroll control in asp.net?

Use below code to help make a marquee!!


<marquee direction="up"  onmouseover="this.stop()" onmouseout="this.start()"
scrolldelay="100" style="height: 100px; width: 400px;">

Demo of marquee tag.

</marquee>

How to Fixed GridView’s Header and Footer when scrolling in vb.net?

Use below 2 Css Classes for GridView Header and footer.


.gridHeader {
font-weight:bold;
background-color: Green;
position:relative;
top:expression(this.parentNode.parentNode.parentNode.scrollTop-1);
}

.gridFooter {
font-weight:bold;
background-color: Green;
position:relative;

bottom:expression(scrollBottom(this.parentNode.parentNode.parentNode.parentNode));
}

Use below JavaScript to compute Footer’s Position.


<script language="javascript" type="text/javascript">

function scrollBottom(p_oElem)
{
return p_oElem.scrollHeight - p_oElem.scrollTop - p_oElem.clientHeight;

}
</script>

Create GridView inside a Panle.


<asp:Panel runat="server" ID="pnlContainer" ScrollBars="Auto" Height="150px" Width="400">
<asp:GridView ShowFooter="True" runat="server" Width="96%" ID="gvDemo"

AutoGenerateColumns="False">
<HeaderStyle CssClass="gridHeader" />
<FooterStyle CssClass="gridFooter" />
<Columns>
<asp:TemplateField HeaderText="a1">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("a1") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
a1 Footer Here
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="a2">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("a2") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
a2 Footer Here
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</asp:Panel>

In the Page_Load function we Bind the data source to GridView in Code Behide:


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim dtbl As New DataTable
dtbl.Columns.Add("a1")
dtbl.Columns.Add("a2")
Dim dr As DataRow
For i As Integer = 0 To 10
dr = dt.NewRow
dr(0) = "a1" & i
dr(1) = "a2" & i
dtbl.Rows.Add(dr)
Next
Me.gvDemo.DataSource = dtbl
Me.gvDemo.DataBind()
End Sub

How to get selected row values in gridview asp.net?

The sample code is below try it:

Use the below code html page.


<asp:GridView runat="server" ID="grdprj"AutoGenerateColumns="false"

OnRowCommand="grdprj_RowCommand">

<Columns>

<asp:BoundField HeaderText="Projcet Name" DataField="ProjectName" />

<asp:ButtonField ButtonType="Link" CommandName="Select" Text="Select" />

</Columns>

</asp:GridView>

Use the below code in code behind page:


protected void grdprj_RowCommand(object sender, GridViewCommandEventArgs e)

{

// If multiple buttons are used in a GridView control, use the

// CommandName property to determine which button was clicked.

if (e.CommandName == "Select")

{

// Convert the row index stored in the CommandArgument

// property to an Integer.

int index_page = Convert.ToInt32(e.CommandArgument);

// Retrieve the row that contains the button clicked

// by the user from the Rows collection.

GridViewRow grdrow = grdprj.Rows[index_page];

}

}

How to make download link in asp.net?

I store images in database as byte array.And I want to open the image in a page after clicking
button.I have tried response.binarywrite() method keeping the page content type=”image” but can not save that in jpg or jpeg format.so how to do in c#?

You use below code:


string FileName ="image1.jpg";
byte[] bytes =  // get from the database table using your DB code/function
Response.Clear();
Response.AppendHeader("Content-Disposition", "filename=" + FileName);
Response.AppendHeader("Content-Length", bytes.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(bytes);
Response.End();

How to read data from excel file using c#?

using OleDB and use the Excel file like a datatable in a database you can read data from excel file.

Like see in below example:


string con = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=path;
Extended Properties='Excel8.0;HDR=Yes;'"
using(OleDbConnection cn= new OleDbConnection(con))
{
cn.Open();
OleDbCommand olcmd = new OleDbCommand("select * from [Sheet1$]", cn)
using(OleDbDataReader dr = olcmd.ExecuteReader())
{
while(dr.Read())
{
var row1Col0 = dr[0];
Console.WriteLine(row1Col0);
}
}
}

Above example use the Microsoft.Jet.OleDb.4.0 provider to open and read the Excel file.

Does not contain a definition and no extension method accepting a first argument of type could be found (are you missing a using directive or an assembly reference?)

Solution of does not contain a definition and no extension method accepting a first argument of type could be found (are you missing a using directive or an assembly reference?).

Just add the below namespace:

System.Xml.Linq.XElement;

How to pass variables or values from one asp vb code page to another?

Using below way to pass variables or values from one asp vb code page to another.

Using session easy way in asp.net/VB.net.
Session(“TestVariable”) = “aaaa”
From another .aspx.vb page you can now use below value. Example:
Dim str as String = “”
str = Session(“TestVariable”)
You can access this page on any of your .aspx pages for using below references .
Session(“TestVariable”).

The type or namespace name ‘Form1′ could not be found (are you missing a using directive or an assembly reference?)

Solution of The type or namespace name ‘Form1′ could not be found (are you missing a using directive or an assembly reference?)

Just add the below namespace:

using System.Windows.Forms;