Saturday, March 31, 2007

Sending Mail Using System.Net.Mail

Code Behind

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
/* Available Only in .NET 2005, it include:
MailMessage,MailAddress,Attachment,SmtpClient.. */

using System.Drawing;
// to Set ForeColor to Label
using System.IO;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{ }
}
protected void btSend_Click(object sender, EventArgs e)
{
try
{

MailMessage mM = new MailMessage();
/*Represents an
e-mail message that can be sent using the SmtpClient class.*/

mM.From = new MailAddress(txtFrom.Text);
/* Gets or sets
the from address for this e-mail message */


mM.To.Add(txtTo.Text);
/* Gets the address collection that
contains the recipients of this e-mail message */

mM.Subject = txtSub.Text;
/* Gets or sets the subject line
for this e-mail message */


mM.Body = txtMsg.Text; /* Message Content */

mM.Priority = MailPriority.High;
/* Gets or sets the priority
of this e-mail message */


SmtpClient sC = new SmtpClient("smtp.mail.yahoo.com");
/* Allows applications to
send e-mail by using the Simple Mail Transfer Protocol (SMTP) */


sC.Port = 587;
 /*Gets or sets the port used for SMTP transactions.*/

sC.Credentials = new NetworkCredential("YahooUsername", "password");/
*Provides credentials
for password-based authentication schemes such as basic, digest, NTLM, and
Kerberos authentication.*/


sC.Send(mM);
/* Overloaded. Sends an e-mail message to an SMTP server
for delivery. These methods block while the message is being transmitted. */


lbReport.Text = "Mail Send Successfully";

lbReport.ForeColor = Color.Green;

}
catch(Exception ex)
{

lbReport.Text = ex+"Mail Sending Fail's";

lbReport.ForeColor = Color.Red;
}
}
}

Inline Code

<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Sending Mail Using System.Net.Mail</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width: 526px">
<tr><td style="width: 116px; height: 26px;">
<strong>From</strong></td><td style="width: 324px; height: 26px;">
<asp:TextBox ID="txtFrom" runat="server" Width="391px"></asp:TextBox></td>
</tr>
<tr><td style="width: 116px; height: 26px;">
<strong>To</strong></td><td style="width: 324px; height: 26px;"><asp:TextBox ID="txtTo" runat="server" Width="392px"></asp:TextBox></td></tr>
<tr><td style="width: 116px">
<strong>Subject</strong></td><td style="width: 324px"><asp:TextBox ID="txtSub" runat="server" Width="394px"></asp:TextBox></td> </tr>
<tr><td style="height: 290px">
<strong>Message</strong></td><td style="height: 290px; width: 324px;">
<asp:TextBox ID="txtMsg" runat="server" Height="284px" TextMode="MultiLine" Width="394px"></asp:TextBox></td></tr>
<tr><td style="height: 5px"></td><td style="width: 324px; height: 5px">
<asp:Button ID="btSend" runat="server" Text="Send" OnClick="btSend_Click" /> <asp:Button ID="btClear"
runat="server" Text="Clear" /></td></tr>
</table>

</div>
<asp:Label ID="lbReport" runat="server" Font-Bold="True" Font-Names="Times New Roman"></asp:Label>
</form>
</body>
</html>



In your IIS Server You Have To Configure,

Step As Follow,

Step 1: Default SMTP Virtual Server.

Step 2:Right-click it.

Step 3:Select Properties.

Step 4:Select Access tab.

Step 5:Click Relay Button.

Step 6:Relay Restriction Dialog Box, only the list below Option Will Be Selected By Default.

Step7:If The local IP address: 127.0.0.1 is Entered Means leave that one else you have to
add the above ip address in The Single Computer Ip address it's enough.



Thursday, March 29, 2007

Convert String To Lower Upper Proper cases

private void Button1_Click(object sender, System.EventArgs e)
{
// TextInfo Class available in System.Globalization namespace;

TextInfo t = new CultureInfo("en-US",false).TextInfo;

//TextInfo Class Defines properties and behaviors, such as casing,
//that are specific to a writing system
Response.Write("LowerCase :"+t.ToLower(TextBox1.Text)+"
ProperCase :"

                                               +t.ToTitleCase(TextBox1.Text)+"
UpperCase :"

                                               +t.ToUpper(TextBox1.Text));
}




Wednesday, March 28, 2007

Convert String To Formatted Date and Time

private void Form1_Load(object sender, System.EventArgs e){
DateTime dt;
string InputDateString = "20070328";
 int iYear =
System.Convert.ToInt32(InputDateString.Substring(0,4));
  int iMonth =
System.Convert.ToInt32(InputDateString.Substring(4,2));
 int iDay =
System.Convert.ToInt32(InputDateString.Substring(6,2));
dt = new DateTime(iYear, iMonth, iDay);
MessageBox.Show(dt.Date.ToString());
MessageBox.Show(dt.Year+" "+dt.Month+", "+dt.Day);
//Change Any Format As You Like It
}



Convert String To Date Format

private void Form1_Load(object sender, System.EventArgs e)
{
string s="3/23/2007";//DateFormat -MM/DD/YY
DateTime dt=new DateTime();
if(s!=null && s.Trim()!="")
dt= System.Convert.ToDateTime(s);
MessageBox.Show(dt.ToString());
}




Friday, March 23, 2007

Get HostName and IP Address

System.Net.IPHostEntry host =new System.Net.IPHostEntry();
private void Page_Load(object sender, System.EventArgs e)
{
host = System.Net.Dns.GetHostByAddress
(Request.ServerVariables["REMOTE_HOST"]);

Response.Write(host.HostName+"\n"+"IP :"+
Request.ServerVariables["REMOTE_ADDR"]);
}






Thursday, March 22, 2007

Create Row Dynamically in DataGrid

HTML Part

< %@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="TestDGrid.WebForm1" % >
< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
< HTML >
< HEAD >
< title >WebForm1< /title >
< meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1" >
< meta name="CODE_LANGUAGE" Content="C#" >
< meta name="vs_defaultClientScript" content="JavaScript" >
< meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5" >
< /HEAD >
< body MS_POSITIONING="GridLayout" >
< form id="Form1" method="post" runat="server" >
< asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 112px; POSITION: absolute; TOP: 16px"
runat="server" AutoGenerateColumns="False" BorderColor="#DEBA84" BorderStyle="None" CellSpacing="2"
BorderWidth="1px" BackColor="#DEBA84" CellPadding="3" >
< SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#738A9C" >< /SelectedItemStyle >
< ItemStyle ForeColor="#8C4510" BackColor="#FFF7E7" >< /ItemStyle >
< HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#A55129" >< /HeaderStyle >
< FooterStyle ForeColor="#8C4510" BackColor="#F7DFB5" >< /FooterStyle >
< Columns >
< asp:TemplateColumn HeaderText="Id" >
< ItemTemplate >
< asp:TextBox id="txtID" runat="server" Text='< %# DataBinder.Eval(Container.DataItem, "iEid ") % >' >
< /asp:TextBox >
< /ItemTemplate >
< /asp:TemplateColumn >
< asp:TemplateColumn HeaderText="Name" >
< ItemTemplate >
< asp:TextBox id="txtName" runat="server" Text='< %# DataBinder.Eval(Container.DataItem, "cEName") % >' >
< /asp:TextBox >
< /ItemTemplate >
< /asp:TemplateColumn >
< asp:TemplateColumn HeaderText="Salary" >
< ItemTemplate >
< asp:TextBox id="txtSal" runat="server" Text='< %# DataBinder.Eval(Container.DataItem, "dSalary") % >' >
< /asp:TextBox >
< /ItemTemplate >
< /asp:TemplateColumn >
< /Columns >
< PagerStyle HorizontalAlign="Center" ForeColor="#8C4510" Mode="NumericPages" >< /PagerStyle >
< /asp:DataGrid >
< asp:Button id="btAdd" style="Z-INDEX: 102; LEFT: 64px; POSITION: absolute; TOP: 24px" runat="server"
Text="Add" >< /asp:Button >
< /form >
< /body >
< /HTML >

CodeBehind

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace TestDGrid
{
///


/// Summary description for WebForm1.
///

public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected DataTable table = new DataTable();
protected System.Web.UI.WebControls.Button btAdd;
SqlConnection con = new SqlConnection(@"Server=IISSERVER;DataBase=TestSenthil;uid=sa;pwd=sa;");
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!IsPostBack)
{ fill();
BindDG();
}
}

public void fill()
{
SqlDataAdapter da = new SqlDataAdapter("Select * from emp",con);
DataSet ds = new DataSet();
da.Fill(table);
}

public void BindDG()
{
DataGrid1.DataSource=table;
DataGrid1.DataBind();
}

public void Nrow()
{
table.Rows.InsertAt(table.NewRow(),0);
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.btAdd.Click += new System.EventHandler(this.btAdd_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void btAdd_Click(object sender, System.EventArgs e)
{
DataGrid1.CurrentPageIndex = 0;
fill();
Nrow();
BindDG();
}
}
}


Monday, March 19, 2007

Calling Server Function From JavaScript

HTML Part

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
                                AutoEventWireup="false" Inherits="CallServerFun.WebForm1" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript"
                     content="JavaScript">
<meta name="vs_targetSchema"
     content="http://schemas.microsoft.com/intellisense/ie5">
<script>
function Ul()
{
var b=document.getElementById("Bt");
b.click();
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" onunload="Ul()">
<form id="Form1" method="post" runat="server">
<button id="Bt" name="Bt" style="DISPLAY:none"
            runat="server" type="button"></button>
</form>
</body>
</HTML>


Code Behind

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace CallServerFun
{
///
/// Summary description for WebForm1.
///

public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlButton Bt;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.Bt.ServerClick += new System.EventHandler
                                 (this.Bt_ServerClick);
this.Load += new System.EventHandler
                              (this.Page_Load);
}
#endregion

private void Bt_ServerClick(object sender,
                             System.EventArgs e)
{
Response.Write("http://www.google.com");
}
}
}



Thursday, March 8, 2007

To Check EmailId Already Exists In The DataBase Or Not

This is the Simple ASP.NET Program to check the Email id is already in the DataBase Or Not,If The Email id exists, Exists Message Will Be Displayed else Available Message Will Be Displayed,This Page Have 4 Web Controls they are as follows,

TextBox Id            =TextBox1
Button Id               =btCheck
Avaiable Label Id = lbAv //PageLoad Visible = false
Exists Label Id     =lbExists // PageLoad Visible = false



Code Behind

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

namespace EmailValidate
{
///


/// Summary description for WebForm1.
///

public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button btCheck;
protected System.Web.UI.WebControls.Label lbAv;
protected System.Web.UI.WebControls.Label lbExists;
SqlConnection con = new SqlConnection(@"Server=servername;DataBase=DataBaseName;uid=sa;pwd=sa;");

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!IsPostBack)
{
}
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.btCheck.Click += new System.EventHandler(this.btCheck_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void btCheck_Click(object sender, System.EventArgs e)
{
SqlDataAdapter da = new SqlDataAdapter(" select * from ScrTest",con);
DataSet ds = new DataSet();
da.Fill(ds,"ScrTest");
DataView dv = new DataView(ds.Tables["ScrTest"]);/*Represents a databindable, customized view of a DataTable for sorting, filtering, searching, editing, and navigation.*/
dv.RowFilter="emailid = '" + TextBox1.Text +"'";
/*Gets or sets the expression used to filter which rows are viewed in the DataView*/
if(dv.Count >0)
//If Count > 0 then Value Aavilable
{
lbExists.Visible=true;
lbAv.Visible=false;
}
else // Not Avaiable
{
lbAv.Visible=true;
lbExists.Visible=false;
}

}
}
}



DataBase Content


Avaiable Email Id

Exists Mail Id




Inserting,Deleting,Updating,Paging With Previous & Number Mode, Manual Paging All Through DataGrid

          This a simple program to insert,delete,update,Navigate Pages,Manually navigate pages in DataGrid

CodeBehind

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

namespace TemplateGrid
{
///


/// Summary description for WebForm1.
///

public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Add;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected DataTable table = new DataTable();
string si;
string is1,is2,is3;
protected System.Web.UI.WebControls.CheckBox chk1;
protected System.Web.UI.WebControls.TextBox TextBox4;
protected System.Web.UI.WebControls.Button Button1;
SqlConnection con = new SqlConnection(@"Server=servername;DataBase=databasename;uid=sa;pwd=sa;");
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!IsPostBack)
{
FillDG();
BindDG();
}
DataGrid1.Columns[3].Visible=true;
DataGrid1.Columns[4].Visible =false;
DataGrid1.Columns[0].Visible=false;
DataGrid1.Columns[1].Visible=false;
}
public void FillDG()
{
SqlDataAdapter da = new SqlDataAdapter("Select * from Emp order by iEid",con);
da.Fill(table);
}
private void InitializeComponent()
{
this.DataGrid1.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_ItemCommand);
this.DataGrid1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid1_PageIndexChanged);
this.chk1.CheckedChanged += new System.EventHandler(this.chk1_CheckedChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
public void BindDG()
{
DataGrid1.DataSource=table;
DataGrid1.DataBind();
}
public void Nrow()
{
table.Rows.InsertAt(table.NewRow(),0);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///


#endregion
private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{}
private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DataGrid1.EditItemIndex = -1;
switch(e.CommandName)
{
case "Add":
DataGrid1.CurrentPageIndex = 0;
DataGrid1.Columns[0].Visible=true;
DataGrid1.Columns[1].Visible=true;
DataGrid1.Columns[2].Visible=false;
DataGrid1.Columns[3].Visible=false;
FillDG();
Nrow();
BindDG();
break;
case "Insert":
SqlDataAdapter ida = new SqlDataAdapter("SELECT MAX(iEid)+1 FROM Emp", con);
DataSet ids = new DataSet();
ida.Fill(ids, "O");
si=Convert.ToString(ids.Tables["O"].Rows[0].ItemArray[0]);
TextBox tEid = new TextBox();
tEid.Text =si;
is1=tEid.Text ;
TextBox tEname=(TextBox)e.Item.Cells[5].FindControl("TextBox2");
is2=tEname.Text;
TextBox tEsal=(TextBox)e.Item.Cells[6].FindControl("TextBox3");
is3=tEsal.Text;
SqlCommand icmd =new SqlCommand("insert into Emp(iEid,cEName,dSalary) values('" + is1+ "','" + tEname.Text +"','" + tEsal.Text + "')",con);
con.Open();
icmd.ExecuteNonQuery();
FillDG();
BindDG();
DataGrid1.Columns[0].Visible=false;
DataGrid1.Columns[1].Visible=false;
DataGrid1.Columns[2].Visible=true;
DataGrid1.Columns[3].Visible=true;
break;
case "Update":
string s1,s2,s3;
TextBox Eid=(TextBox)e.Item.Cells[4].FindControl("TextBox1");
s1=Eid.Text;
TextBox Ename=(TextBox)e.Item.Cells[5].FindControl("TextBox2");
s2=Ename.Text;
TextBox Esal=(TextBox)e.Item.Cells[6].FindControl("TextBox3");
s3=Esal.Text;
SqlCommand cmd =new SqlCommand("Update Emp Set dSalary=" + s3+ " ,cEName ='" + s2 + "' WHERE iEid=" + Convert.ToInt32(s1),con);
con.Open();
cmd.ExecuteNonQuery();
FillDG();
BindDG();
Response.Write("Update");
break;
case "Edit":
DataGrid1.EditItemIndex=e.Item.ItemIndex;
FillDG();
BindDG();
break;
case "Delete":
string s11;
s11=Convert.ToString(e.Item.Cells[4].Text);
Response.Write(s11);
TextBox iEid=(TextBox)e.Item.Cells[5].FindControl("TextBox2");
s11=iEid.Text;
SqlCommand Dcmd =new SqlCommand("Delete from emp where cEName= '"+ s11 +"' ",con);
con.Open();
Dcmd.ExecuteNonQuery();
FillDG();
BindDG();

break;
case "Cancel":
DataGrid1.Columns[2].Visible=true;
DataGrid1.EditItemIndex=-1;
FillDG();
BindDG();
break;
case "GoTo":
TextBox GT=(TextBox)e.Item.Cells[5].FindControl("TextBox5");
string GTs=GT.Text;
DataGrid1.CurrentPageIndex =Convert.ToInt16(GTs);
FillDG();
BindDG();
break;
}
}
private void chk1_CheckedChanged(object sender, System.EventArgs e)
{
if (chk1.Checked)
{
DataGrid1.PagerStyle.Mode=PagerMode.NumericPages;
chk1.Text="Changed To NextPrev";
DataGrid1.Columns[2].Visible=true;
FillDG();
BindDG();
}
else
{
DataGrid1.PagerStyle.Mode=PagerMode.NextPrev;
chk1.Text="NumericPages";
DataGrid1.Columns[2].Visible=true;
FillDG();
BindDG();
}
}
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex=e.NewPageIndex;
FillDG();
BindDG();
}
}
}


HTML Part

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="TemplateGrid.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 48px; POSITION: absolute; TOP: 40px" runat="server"
AutoGenerateColumns="False" Width="483px" BorderColor="#999999" BorderStyle="None" BorderWidth="1px"
BackColor="White" CellPadding="3" GridLines="Vertical" PageSize="3" AllowPaging="True" AllowSorting="True"
ShowFooter="True">
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#008A8C"></SelectedItemStyle>
<AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle>
<ItemStyle ForeColor="Black" BackColor="#EEEEEE"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#000084"></HeaderStyle>
<FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle>
<Columns>
<asp:ButtonColumn Text="Insert" CommandName="Insert"></asp:ButtonColumn>
<asp:ButtonColumn Text="Cancel" CommandName="Cancel"></asp:ButtonColumn>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
<asp:ButtonColumn Text="Delete" CommandName="Delete"></asp:ButtonColumn>
<asp:TemplateColumn>
<HeaderTemplate>
Emp_Id
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox id=TextBox1 runat="server" Width="64px" Text='<%# DataBinder.Eval(Container.DataItem, "iEid") %>'>
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderTemplate>
Employee_Name
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox id=TextBox2 runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "cEName") %>' MaxLength="25">
</asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="TextBox5" runat="server" Width="56px"></asp:TextBox>
<asp:Button id="btGoTo" runat="server" Text="GoTo" Font-Bold="True" Font-Names="Times New Roman"
CommandName="GoTo"></asp:Button>
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderTemplate>
Employee Salary
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox id=TextBox3 runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "dSalary") %>' MaxLength="7">
</asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:Button id="Add" runat="server" Text="Add" CommandName="Add"></asp:Button>
</FooterTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle NextPageText="Next »" PrevPageText="« Prev" HorizontalAlign="Center" ForeColor="Black"
BackColor="#999999"></PagerStyle>
</asp:datagrid>
<p><asp:Checkbox id="chk1" runat="server" Text="NumericPages" Font-Name="Verdana" Font-Size="8pt"
AutoPostBack="true" style="Z-INDEX: 102; LEFT: 8px; POSITION: absolute; TOP: 16px" />
</p>
</form>
</body>
</HTML>



Table Struture
Table Name = Emp



Intial Screen

Paging Style
when the Checked Box is Checked then Paging Mode will changed to Number Mode If Unchecked it will be in Previous&Next Mode

Manually Changing The Page
You can manually navigate Pages Through Passing the needed page number in the TextBox and Click GoTo Button,It will display the Corresponding Page,The Page Index Starts Form 0 to n,

Inserting A Row

You can insert a record through DataGrid,When You Clicked the Add Button new DataTable will inserted,


Creative Commons License
Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.