hello
asp.net c#,sql server,use sqlhelper class, funcation,class,store procedure,view,triggers,call email class in asp.net c#,MVC AND ENTITY FRAMEWORK TUTORIAL,how to create database with script using c#,datareader with sqlhelper and run time label bind in grid,insert update select storprocedure Delete duplicate record in database,Delete duplicate record in database,how add connection string,how add connection string
Monday, 26 September 2011
Friday, 23 September 2011
My Project
N=BUSSNESS ERP
MARKETING MANAGMENT
ENVENTORY MANAGMENT
STOCK MANAGMENT
IN ERICSSON
(OEE FOR RADIOUS TESTING, DPL,ISS,OMS,HRMDB,VMS,OIL,RAIL,ASR,HR TRAINING MODUAL)
HOTEL PORTAL
HOTEL MANAGMENT
MARKETING MANAGMENT
ENVENTORY MANAGMENT
STOCK MANAGMENT
IN ERICSSON
(OEE FOR RADIOUS TESTING, DPL,ISS,OMS,HRMDB,VMS,OIL,RAIL,ASR,HR TRAINING MODUAL)
HOTEL PORTAL
HOTEL MANAGMENT
Thursday, 18 August 2011
how stop cut copy pest
<asp:TextBox ID="TextBox1" runat="server"
oncopy="return false"
onpaste="return false"
oncut="return false">
</asp:TextBox>
Wednesday, 27 July 2011
linq to sql select/insert/update/delete
DataClassesDataContext db = new DataClassesDataContext();
var challan = from c in db.viewchallans where c.Brand_Name=="Brand"
select c;
GridView1.DataSource = challan;
GridView1.DataBind();
DataClassesDataContext db = new DataClassesDataContext();
{
buddget bud = new buddget
{
Buddegerbetwwen = "2000000"
};
db.buddgets.InsertOnSubmit(bud);
db.SubmitChanges();
}
DataClassesDataContext db = new DataClassesDataContext();
var challan = from c in db.viewchallans where c.Brand_Name.Contains("Brand")
select c;
db.SubmitChanges();
Tuesday, 26 July 2011
search folder from system
using System;
using System.IO;
using System.Collections;
public class RecursiveFileProcessor
{
public static void Main(string[] args)
{
foreach(string path in args)
{
if(File.Exists(path))
{
// This path is a file
ProcessFile(path);
}
else if(Directory.Exists(path))
{
// This path is a directory
ProcessDirectory(path);
}
else
{
Console.WriteLine("{0} is not a valid file or directory.", path);
}
}
}
//
public static void ProcessDirectory(string targetDirectory)
{
// Process the list of files found in the directory.
string [] fileEntries = Directory.GetFiles(targetDirectory);
foreach(string fileName in fileEntries)
ProcessFile(fileName);
// Recurse into subdirectories of this directory.
string [] subdirectoryEntries = Directory.GetDirectories(targetDirectory);
foreach(string subdirectory in subdirectoryEntries)
ProcessDirectory(subdirectory);
}
// Insert logic for processing found files here.
public static void ProcessFile(string path)
{
Console.WriteLine("Processed file '{0}'.", path);
}
}
using System.IO;
using System.Collections;
public class RecursiveFileProcessor
{
public static void Main(string[] args)
{
foreach(string path in args)
{
if(File.Exists(path))
{
// This path is a file
ProcessFile(path);
}
else if(Directory.Exists(path))
{
// This path is a directory
ProcessDirectory(path);
}
else
{
Console.WriteLine("{0} is not a valid file or directory.", path);
}
}
}
//
public static void ProcessDirectory(string targetDirectory)
{
// Process the list of files found in the directory.
string [] fileEntries = Directory.GetFiles(targetDirectory);
foreach(string fileName in fileEntries)
ProcessFile(fileName);
// Recurse into subdirectories of this directory.
string [] subdirectoryEntries = Directory.GetDirectories(targetDirectory);
foreach(string subdirectory in subdirectoryEntries)
ProcessDirectory(subdirectory);
}
// Insert logic for processing found files here.
public static void ProcessFile(string path)
{
Console.WriteLine("Processed file '{0}'.", path);
}
}
Turing in Asp.net
Bitmap objBMP = new System.Drawing.Bitmap(60, 20);
Graphics objGraphics = System.Drawing.Graphics.FromImage(objBMP);
objGraphics.Clear(Color.Chocolate);
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
//' Configure font to use for text
Font objFont = new Font("Arial", 8, FontStyle.Bold);
string randomStr = "";
int[] myIntArray = new int[5];
int x;
//That is to create the random # and add it to our string
Random autoRand = new Random();
for (x = 0; x < 5; x++)
{
myIntArray[x] = System.Convert.ToInt32(autoRand.Next(0, 9));
randomStr += (myIntArray[x].ToString());
}
//This is to add the string to session cookie, to be compared later
Session.Add("randomStr", randomStr);
//' Write out the text
objGraphics.DrawString(randomStr, objFont, Brushes.White, 3, 3);
//' Set the content type and return the image
Response.ContentType = "image/GIF";
objBMP.Save(Response.OutputStream, ImageFormat.Gif);
objFont.Dispose();
objGraphics.Dispose();
objBMP.Dispose();
if (Page.IsValid && (txtTuring.Text == Session["randomStr"].ToString()))
{
}
Graphics objGraphics = System.Drawing.Graphics.FromImage(objBMP);
objGraphics.Clear(Color.Chocolate);
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
//' Configure font to use for text
Font objFont = new Font("Arial", 8, FontStyle.Bold);
string randomStr = "";
int[] myIntArray = new int[5];
int x;
//That is to create the random # and add it to our string
Random autoRand = new Random();
for (x = 0; x < 5; x++)
{
myIntArray[x] = System.Convert.ToInt32(autoRand.Next(0, 9));
randomStr += (myIntArray[x].ToString());
}
//This is to add the string to session cookie, to be compared later
Session.Add("randomStr", randomStr);
//' Write out the text
objGraphics.DrawString(randomStr, objFont, Brushes.White, 3, 3);
//' Set the content type and return the image
Response.ContentType = "image/GIF";
objBMP.Save(Response.OutputStream, ImageFormat.Gif);
objFont.Dispose();
objGraphics.Dispose();
objBMP.Dispose();
if (Page.IsValid && (txtTuring.Text == Session["randomStr"].ToString()))
{
}
convert date dd/mm/yyyy to mm/dd/yyyy in asp.net
DateTime dtt1;
dtt1 = Convert.ToDateTime(txtDD.Text, System.Globalization.CultureInfo.CreateSpecificCulture("en-CA"));
dtt1 = Convert.ToDateTime(txtDD.Text, System.Globalization.CultureInfo.CreateSpecificCulture("en-CA"));
globla .asax file in asp.net
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
Session.Timeout = 1440;
Session["user"] = "";
Session["LoginBy"] = "";
}
{
// Code that runs when a new session is started
Session.Timeout = 1440;
Session["user"] = "";
Session["LoginBy"] = "";
}
array in data set
for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
String m = ds.Tables[0].Rows[i].ItemArray[0].ToString();
String m1 = ds.Tables[0].Rows[i].ItemArray[6].ToString();
String m2 = ds.Tables[0].Rows[i].ItemArray[12].ToString();
string m3 = ds.Tables[0].Rows[i].ItemArray[13].ToString();
string insert = "insert into table(aaa,aa,aa,aa) values('" + Gpcode + "','" + m + "','" + m1 + "','" + m2 + "')";
SqlHelper.ExecuteNonQuery(con, CommandType.Text, insert);
}
{
String m = ds.Tables[0].Rows[i].ItemArray[0].ToString();
String m1 = ds.Tables[0].Rows[i].ItemArray[6].ToString();
String m2 = ds.Tables[0].Rows[i].ItemArray[12].ToString();
string m3 = ds.Tables[0].Rows[i].ItemArray[13].ToString();
string insert = "insert into table(aaa,aa,aa,aa) values('" + Gpcode + "','" + m + "','" + m1 + "','" + m2 + "')";
SqlHelper.ExecuteNonQuery(con, CommandType.Text, insert);
}
how to fill tree view dynamicaly
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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.Data.SqlClient;
public partial class dynamictreeview : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void TreeView1_TreeNodePopulate(object sender, TreeNodeEventArgs e)
{
if (e.Node.ChildNodes.Count == 0)
{
switch (e.Node.Depth)
{
case 0:
fillcategory(e.Node);
break;
case 1:
fillsubcat(e.Node);
break;
}
}
}
public void fillcategory(TreeNode node)
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
con.Open();
string qry = "select * from tbl_category";
SqlDataAdapter ad = new SqlDataAdapter(qry, con);
DataSet ds = new DataSet();
try
{
ad.Fill(ds);
}
catch (Exception ex)
{
}
if (ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow r in ds.Tables[0].Rows)
{
TreeNode newnode = new TreeNode(r["catname"].ToString() , r["catid"].ToString());
newnode.PopulateOnDemand = true;
node.ChildNodes.Add(newnode);
}
}
}
public void fillsubcat(TreeNode node)
{
string aid = node.Value;
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
con.Open();
string qry = "select subcatid,subcatname from tbl_subcategory where catid='" + aid + "'";
SqlDataAdapter ad = new SqlDataAdapter(qry, con);
DataSet ds = new DataSet();
try
{
ad.Fill(ds);
}
catch (Exception ex)
{
}
if (ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow r in ds.Tables[0].Rows)
{
TreeNode newnode = new TreeNode(r["subcatname"].ToString(), r["subcatid"].ToString());
newnode.PopulateOnDemand = false;
newnode.SelectAction = TreeNodeSelectAction.None;
node.ChildNodes.Add(newnode);
}
}
}
}
using System.Data;
using System.Configuration;
using System.Collections;
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.Data.SqlClient;
public partial class dynamictreeview : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void TreeView1_TreeNodePopulate(object sender, TreeNodeEventArgs e)
{
if (e.Node.ChildNodes.Count == 0)
{
switch (e.Node.Depth)
{
case 0:
fillcategory(e.Node);
break;
case 1:
fillsubcat(e.Node);
break;
}
}
}
public void fillcategory(TreeNode node)
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
con.Open();
string qry = "select * from tbl_category";
SqlDataAdapter ad = new SqlDataAdapter(qry, con);
DataSet ds = new DataSet();
try
{
ad.Fill(ds);
}
catch (Exception ex)
{
}
if (ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow r in ds.Tables[0].Rows)
{
TreeNode newnode = new TreeNode(r["catname"].ToString() , r["catid"].ToString());
newnode.PopulateOnDemand = true;
node.ChildNodes.Add(newnode);
}
}
}
public void fillsubcat(TreeNode node)
{
string aid = node.Value;
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
con.Open();
string qry = "select subcatid,subcatname from tbl_subcategory where catid='" + aid + "'";
SqlDataAdapter ad = new SqlDataAdapter(qry, con);
DataSet ds = new DataSet();
try
{
ad.Fill(ds);
}
catch (Exception ex)
{
}
if (ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow r in ds.Tables[0].Rows)
{
TreeNode newnode = new TreeNode(r["subcatname"].ToString(), r["subcatid"].ToString());
newnode.PopulateOnDemand = false;
newnode.SelectAction = TreeNodeSelectAction.None;
node.ChildNodes.Add(newnode);
}
}
}
}
trigger in sqlserver
- . DML Triggers
create trigger afterinsert_trigger
on emp
AFTER INSERT
as
PRINT 'AFTER TRIGGER EXECUTED SUCESSFULLY'
GO
Update
create trigger afterupdate_trigger
on emp
AFTER UPDATE
as
PRINT 'AFTER UPDATE TRIGGER EXECUTED SUCESSFULLY'
GO
Delete
Create trigger afterdelete_trigger
On emp
AFTER DELETE
as
PRINT 'AFTER DELETE TRIGGER EXECUTED SUCESSFULLY'
GOInstead of Delete Trigger
Creating INSTEAD OF DELETE TRIGGER:-create trigger insteadofdelete_trigger
on emp
INSTEAD OF DELETE
as
PRINT 'INSTEAD OF DELETE TRIGGER EXECUTED SUCESSFULLY'
GO
HOW TO Drop a Trigger?
Syntax: DROP TRIGGER [triggername]
Eg: DROP TRIGGER afterinsert_triggercursor in sqlserver2005
USE AdventureWorks
GO
DECLARE @ProductID INT
DECLARE @getProductID CURSOR
SET @getProductID = CURSOR FOR
SELECT ProductID
FROM Production.Product
OPEN @getProductID
FETCH NEXT
FROM @getProductID INTO @ProductID
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @ProductID
FETCH NEXT
FROM @getProductID INTO @ProductID
END
CLOSE @getProductID
DEALLOCATE @getProductID
GO
Monday, 25 July 2011
message show
Page.ClientScript.RegisterStartupScript(typeof(Page), "Voucher No ", "alert('Please Try Again')", true);
||
Response.Write(@"<script language='javascript'>alert('Please Credit First ');</script>");
||
Response.Write(@"<script language='javascript'>alert('Please Credit First ');</script>");
how can back up of database
create folder with name of backup
SqlConnection con = new SqlConnection("Data Source=aa\\
SQLEXPRESS;Initial Catalog=aa;Integrated Security=True");
SqlCommand cmd = new SqlCommand("backup database aa to disk = '" + Server.MapPath("~/backup/aa. bak") + "' ", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
SqlConnection con = new SqlConnection("Data Source=aa\\
SqlCommand cmd = new SqlCommand("backup database aa to disk = '" + Server.MapPath("~/backup/aa.
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Transcation in asp.net C#
SqlTransaction tr;
con.Open();
string save1 = "insert into table(userid,worktime,date) values('" + Session["id"].ToString() + "','" + System.DateTime.Now.ToString() + "','"+dtn1+"')";
SqlCommand com1 = new SqlCommand(save1, con);
tr = con.BeginTransaction();
com1.Transaction = tr;
com1.ExecuteNonQuery();
tr.Commit();
con.Close();
catch (Exception ex)
{
tr.Rollback();
}
con.Open();
string save1 = "insert into table(userid,worktime,date) values('" + Session["id"].ToString() + "','" + System.DateTime.Now.ToString() + "','"+dtn1+"')";
SqlCommand com1 = new SqlCommand(save1, con);
tr = con.BeginTransaction();
com1.Transaction = tr;
com1.ExecuteNonQuery();
tr.Commit();
con.Close();
catch (Exception ex)
{
tr.Rollback();
}
Sunday, 24 July 2011
store proc
create proc [dbo].[UpdateAddClient]
@ID numeric(10, 0),
@Applicant nvarchar(50),
@REFRANCE nvarchar(50),
@FLATTYPE nvarchar(50),
@REMARK1 nvarchar(50),
as
begin
update CLIENT set Applicant=@Applicant,REFRANCE=@REFRANCE,FLATTYPE=@FLATTYPE,REMARK1=@REMARK1
end
@ID numeric(10, 0),
@Applicant nvarchar(50),
@REFRANCE nvarchar(50),
@FLATTYPE nvarchar(50),
@REMARK1 nvarchar(50),
as
begin
update CLIENT set Applicant=@Applicant,REFRANCE=@REFRANCE,FLATTYPE=@FLATTYPE,REMARK1=@REMARK1
end
insert/update/delete/select query
string ss1 = "select * from table where Scheame='" + _aaa+ "' ";
string ss2 = "update table set Amount='" + _amount + "',PlcAmount='"+_amountplc+"' where id='" + _Id + "'";
string ssss = "delete from table where CINVNO='" + _CINVNO + "'";
string ssss = "delete from table where CINVNO='" + _CINVNO + "'";
string cmdsave1 = "insert into table (CINVNO,PROJECTCODE,LEDGERCODE) values('" + Mvoucherno + "','" + Mprojectcode + "','" + txtpartycode.Text + "') ";
how pass perametres in storprocedure
public void saveaddress1(string _LEDGERCODE, string _GRCODE, string _NAME, string _ADD1, string _ADD2, string _ADD3, string _city, string _State, string _PIN, string _PHONE, string _MOBILE, string _EmailId, string _UserId, string _WorkTime)
{
SqlConnection con = new SqlConnection(connection.connect);
con.Open();
SqlParameter[] parm = new SqlParameter[14];
parm[0] = new SqlParameter("@LEDGERCODE", _LEDGERCODE);
parm[1] = new SqlParameter("@GRCODE", _GRCODE);
parm[2] = new SqlParameter("@NAME", _NAME);
parm[3] = new SqlParameter("@ADD1", _ADD1);
parm[4] = new SqlParameter("@ADD2", _ADD2);
parm[5] = new SqlParameter("@ADD3", _ADD3);
parm[6] = new SqlParameter("@city", _city);
parm[7] = new SqlParameter("@State", _State);
parm[8] = new SqlParameter("@PIN", _PIN);
parm[9] = new SqlParameter("@PHONE", _PHONE);
parm[10] = new SqlParameter("@MOBILE", _MOBILE);
parm[11] = new SqlParameter("@EmailId", _EmailId);
parm[12] = new SqlParameter("@UserId", _UserId);
parm[13] = new SqlParameter("@WorkTime", _WorkTime);
SqlCommand com = new SqlCommand("saveaddress", con);
com.CommandType = CommandType.StoredProcedure;
for (int i = 0; i < 14; i++)
{
com.Parameters.Add(parm[i]);
}
com.ExecuteNonQuery();
con.Close();
}
{
SqlConnection con = new SqlConnection(connection.connect);
con.Open();
SqlParameter[] parm = new SqlParameter[14];
parm[0] = new SqlParameter("@LEDGERCODE", _LEDGERCODE);
parm[1] = new SqlParameter("@GRCODE", _GRCODE);
parm[2] = new SqlParameter("@NAME", _NAME);
parm[3] = new SqlParameter("@ADD1", _ADD1);
parm[4] = new SqlParameter("@ADD2", _ADD2);
parm[5] = new SqlParameter("@ADD3", _ADD3);
parm[6] = new SqlParameter("@city", _city);
parm[7] = new SqlParameter("@State", _State);
parm[8] = new SqlParameter("@PIN", _PIN);
parm[9] = new SqlParameter("@PHONE", _PHONE);
parm[10] = new SqlParameter("@MOBILE", _MOBILE);
parm[11] = new SqlParameter("@EmailId", _EmailId);
parm[12] = new SqlParameter("@UserId", _UserId);
parm[13] = new SqlParameter("@WorkTime", _WorkTime);
SqlCommand com = new SqlCommand("saveaddress", con);
com.CommandType = CommandType.StoredProcedure;
for (int i = 0; i < 14; i++)
{
com.Parameters.Add(parm[i]);
}
com.ExecuteNonQuery();
con.Close();
}
how pass perametres in storprocedure using sqlhelper
public void savereqesthead()
{
MySqlHelper.ExecuteNonQuery(connection.connect, CommandType.StoredProcedure, "saverequestionhead", , new SqlParameter("@DATE", _Date), , new SqlParameter("@WorkTime", _WorkTime));
}
{
MySqlHelper.ExecuteNonQuery(connection.connect, CommandType.StoredProcedure, "saverequestionhead", , new SqlParameter("@DATE", _Date), , new SqlParameter("@WorkTime", _WorkTime));
}
how create connection class
public class connection
{
public connection()
{
}
public static string connect
{
get
{
return aaa\\SQLEXPRESS;Initial Catalog=aaa;Integrated Security=True";
}
}
}
{
public connection()
{
}
public static string connect
{
get
{
return aaa\\SQLEXPRESS;Initial Catalog=aaa;Integrated Security=True";
}
}
}
how to set property in a class
public class purchaseorderpage
{
SqlTransaction tr;
public purchaseorderpage()
{ }
private string _Id;
public string Id
{ get { return _Id; } set { _Id = value; } }
{
SqlTransaction tr;
public purchaseorderpage()
{ }
private string _Id;
public string Id
{ get { return _Id; } set { _Id = value; } }
how add string
lbladd1.Text = rd["RADD1"].ToString() + " " + rd["RADD2"].ToString() + " " + rd["RADD3"].ToString() + " " + rd["RCITY"].ToString() + " (" + rd["rstate"].ToString() + ") - " + rd["RPIN"].ToString();
how call mail class
mailsending objmail = new mailsending();// create object
string messages = "Your Account in Name of"
objmail.send(lblmailid.Text, messages);
string messages = "Your Account in Name of"
objmail.send(lblmailid.Text, messages);
Saturday, 23 July 2011
accordin penal
First Add Jquey file
<script type="text/javascript">
ddaccordion.init({
headerclass: "submenuheader", //Shared CSS class name of headers group
contentclass: "submenu", //Shared CSS class name of contents group
revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
animatedefault: false, //Should contents open by default be animated into view?
persiststate: true, //persist state of opened contents within browser session?
toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
togglehtml: ["suffix", "<img src='plus.gif' class='statusicon' />", "<img src='minus.gif' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively ["position", "html1", "html2"] (see docs)
animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
//do nothing
},
onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
//do nothing
}
})
</script>
<style type="text/css">
.body
{
font-family: Arial;
font-size: 14px;
}
.glossymenu
{
margin: 0px 0;
padding: 0;
width: 170px; /*width of menu*/
border: 1px solid #9A9A9A;
border-bottom-width: 0;
}
.glossymenu a.menuitem
{
background: black url(js/glossyback.gif) repeat-x bottom left;
font: bold 14px "Lucida Grande" , "Trebuchet MS" , Verdana, Helvetica, sans-serif;
color: white;
display: block;
position: relative; /*To help in the anchoring of the ".statusicon" icon image*/
width: auto;
padding: 4px 0;
padding-left: 10px;
text-decoration: none;
}
.glossymenu a.menuitem:visited, .glossymenu .menuitem:active
{
color: white;
}
.glossymenu a.menuitem .statusicon
{
/*CSS for icon image that gets dynamically added to headers*/
position: absolute;
top: 5px;
right: 5px;
border: none;
}
.glossymenu a.menuitem:hover
{
background-image: url(js/glossyback2.gif);
}
.glossymenu div.submenu
{
/*DIV that contains each sub menu*/
background: white;
}
.glossymenu div.submenu ul
{
/*UL of each sub menu*/
list-style-type: none;
margin: 0;
padding: 0;
}
.glossymenu div.submenu ul li
{
border-bottom: 1px solid blue;
}
.glossymenu div.submenu ul li a
{
display: block;
font: normal 13px "Lucida Grande" , "Trebuchet MS" , Verdana, Helvetica, sans-serif;
color: black;
text-decoration: none;
padding: 2px 0;
padding-left: 10px;
}
.glossymenu div.submenu ul li a:hover
{
background: #DFDCCB;
color: White;
}
</style>
<div class="glossymenu">
<asp:Panel ID="pnltrans" runat="server" Visible="false">
<a class="menuitem submenuheader" href="#">
home
</a>
<div class="submenu">
<ul>
<%--li><a href="">home1</a></li>
<li><a href="">home2</a></li>
<li><a href="">home3</a></li>
<li><a href="">home4</a></li>
</ul>
</div>
<script type="text/javascript">
ddaccordion.init({
headerclass: "submenuheader", //Shared CSS class name of headers group
contentclass: "submenu", //Shared CSS class name of contents group
revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
animatedefault: false, //Should contents open by default be animated into view?
persiststate: true, //persist state of opened contents within browser session?
toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
togglehtml: ["suffix", "<img src='plus.gif' class='statusicon' />", "<img src='minus.gif' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively ["position", "html1", "html2"] (see docs)
animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
//do nothing
},
onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
//do nothing
}
})
</script>
<style type="text/css">
.body
{
font-family: Arial;
font-size: 14px;
}
.glossymenu
{
margin: 0px 0;
padding: 0;
width: 170px; /*width of menu*/
border: 1px solid #9A9A9A;
border-bottom-width: 0;
}
.glossymenu a.menuitem
{
background: black url(js/glossyback.gif) repeat-x bottom left;
font: bold 14px "Lucida Grande" , "Trebuchet MS" , Verdana, Helvetica, sans-serif;
color: white;
display: block;
position: relative; /*To help in the anchoring of the ".statusicon" icon image*/
width: auto;
padding: 4px 0;
padding-left: 10px;
text-decoration: none;
}
.glossymenu a.menuitem:visited, .glossymenu .menuitem:active
{
color: white;
}
.glossymenu a.menuitem .statusicon
{
/*CSS for icon image that gets dynamically added to headers*/
position: absolute;
top: 5px;
right: 5px;
border: none;
}
.glossymenu a.menuitem:hover
{
background-image: url(js/glossyback2.gif);
}
.glossymenu div.submenu
{
/*DIV that contains each sub menu*/
background: white;
}
.glossymenu div.submenu ul
{
/*UL of each sub menu*/
list-style-type: none;
margin: 0;
padding: 0;
}
.glossymenu div.submenu ul li
{
border-bottom: 1px solid blue;
}
.glossymenu div.submenu ul li a
{
display: block;
font: normal 13px "Lucida Grande" , "Trebuchet MS" , Verdana, Helvetica, sans-serif;
color: black;
text-decoration: none;
padding: 2px 0;
padding-left: 10px;
}
.glossymenu div.submenu ul li a:hover
{
background: #DFDCCB;
color: White;
}
</style>
<div class="glossymenu">
<asp:Panel ID="pnltrans" runat="server" Visible="false">
<a class="menuitem submenuheader" href="#">
home
</a>
<div class="submenu">
<ul>
<%--li><a href="">home1</a></li>
<li><a href="">home2</a></li>
<li><a href="">home3</a></li>
<li><a href="">home4</a></li>
</ul>
</div>
check box event
foreach (GridViewRow rows in gvModification.Rows)
{
CheckBox ch = (CheckBox)rows.FindControl("chkrejct");
if (ch.Checked && ch.Enabled == true)
{
int id = Convert.ToInt32(gvModification.DataKeys[rows.RowIndex].Value);
}
}
{
CheckBox ch = (CheckBox)rows.FindControl("chkrejct");
if (ch.Checked && ch.Enabled == true)
{
int id = Convert.ToInt32(gvModification.DataKeys[rows.RowIndex].Value);
}
}
array searching
public void fillgrid()
{
bool Mbook = false;
string[] filld = new string[2];
string[] oper = new string[2];
string[] val = new string[2];
int k = 0;
bool Mcommon = false;
string str = "select * from View_avlflat where FLATNO!='999' and BOOK='" + Mbook + "' and common='" + Mcommon + "' and ";
if (ddlprojectsite.SelectedIndex != 0)
{
filld[k] = "PROJECTCODE";
oper[k] = "="; ;
val[k] = "'" + ddlprojectsite.SelectedValue + "'";
k++;
}
if (ddlFlateType.SelectedIndex != 0)
{
filld[k] = "flattypeId";
oper[k] = "="; ;
val[k] = "'" + ddlFlateType.SelectedValue + "'";
k++;
}
for (int i = 0; i < k; i++)
{
str = str + filld[i] + oper[i] + val[i] + " and ";
}
//if (str.Substring(str.Length - 4, 4) == "and ")
//{
str = str.Substring(0, str.Length - 4);
//}
con.Open();
SqlDataAdapter da = new SqlDataAdapter(str, con);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
gvflateavalable.DataSource = ds;
gvflateavalable.DataBind();
if (gvflateavalable.Rows.Count > 0)
{
Button3.Visible = true;
Button4.Visible = true;
}
ReportViewer1.LocalReport.DataSources.Clear();
ReportDataSource reportDSHeader = new ReportDataSource("AvailableFlat_View_avlflat", ds.Tables[0]);
ReportViewer1.LocalReport.DataSources.Add(reportDSHeader);
ReportViewer1.LocalReport.Refresh();
}
{
bool Mbook = false;
string[] filld = new string[2];
string[] oper = new string[2];
string[] val = new string[2];
int k = 0;
bool Mcommon = false;
string str = "select * from View_avlflat where FLATNO!='999' and BOOK='" + Mbook + "' and common='" + Mcommon + "' and ";
if (ddlprojectsite.SelectedIndex != 0)
{
filld[k] = "PROJECTCODE";
oper[k] = "="; ;
val[k] = "'" + ddlprojectsite.SelectedValue + "'";
k++;
}
if (ddlFlateType.SelectedIndex != 0)
{
filld[k] = "flattypeId";
oper[k] = "="; ;
val[k] = "'" + ddlFlateType.SelectedValue + "'";
k++;
}
for (int i = 0; i < k; i++)
{
str = str + filld[i] + oper[i] + val[i] + " and ";
}
//if (str.Substring(str.Length - 4, 4) == "and ")
//{
str = str.Substring(0, str.Length - 4);
//}
con.Open();
SqlDataAdapter da = new SqlDataAdapter(str, con);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
gvflateavalable.DataSource = ds;
gvflateavalable.DataBind();
if (gvflateavalable.Rows.Count > 0)
{
Button3.Visible = true;
Button4.Visible = true;
}
ReportViewer1.LocalReport.DataSources.Clear();
ReportDataSource reportDSHeader = new ReportDataSource("AvailableFlat_View_avlflat", ds.Tables[0]);
ReportViewer1.LocalReport.DataSources.Add(reportDSHeader);
ReportViewer1.LocalReport.Refresh();
}
view
SELECT dbo.PURCHASESORDERBOM.PURBOMID, dbo.PURCHASESORDERBOM.DATE, dbo.ITEM.ITEMNAME, dbo.PURCHASESORDER.CINVNO AS cno,
dbo.PURCHASESORDERBOM.CQTY, dbo.PURCHASESORDERBOM.CRATE, dbo.PURCHASESORDERBOM.VALUE AS amt,
dbo.PURCHASESORDERBOM.VATAMT, dbo.PURCHASESORDERBOM.DIS, dbo.PURCHASESORDERBOM.DISAMT, dbo.PURCHASESORDERBOM.TOTAL,
dbo.PURCHASESORDERBOM.Complit, dbo.PURCHASESORDERBOM.Brand_Name, dbo.PURCHASESORDERBOM.ProjectSite,
dbo.PURCHASESORDER.LEDGERCODE, dbo.LEDGER.NAME, dbo.PURCHASESORDER.DATE AS Expr2, dbo.PURCHASESORDER.DELDATE,
dbo.PURCHASESORDER.Remarks, dbo.PURCHASESORDER.PARTYBILLNO, dbo.ITEM.ITEMCODE, dbo.ITEM.VAT,
dbo.PURCHASESORDERBOM.Reqision
FROM dbo.PURCHASESORDERBOM INNER JOIN
dbo.ITEM ON dbo.PURCHASESORDERBOM.ITEMCODE = dbo.ITEM.ITEMCODE INNER JOIN
dbo.PURCHASESORDER ON dbo.PURCHASESORDERBOM.CINVNO = dbo.PURCHASESORDER.CINVNO INNER JOIN
dbo.LEDGER ON dbo.PURCHASESORDER.LEDGERCODE = dbo.LEDGER.LEDGERCODE
dbo.PURCHASESORDERBOM.CQTY, dbo.PURCHASESORDERBOM.CRATE, dbo.PURCHASESORDERBOM.VALUE AS amt,
dbo.PURCHASESORDERBOM.VATAMT, dbo.PURCHASESORDERBOM.DIS, dbo.PURCHASESORDERBOM.DISAMT, dbo.PURCHASESORDERBOM.TOTAL,
dbo.PURCHASESORDERBOM.Complit, dbo.PURCHASESORDERBOM.Brand_Name, dbo.PURCHASESORDERBOM.ProjectSite,
dbo.PURCHASESORDER.LEDGERCODE, dbo.LEDGER.NAME, dbo.PURCHASESORDER.DATE AS Expr2, dbo.PURCHASESORDER.DELDATE,
dbo.PURCHASESORDER.Remarks, dbo.PURCHASESORDER.PARTYBILLNO, dbo.ITEM.ITEMCODE, dbo.ITEM.VAT,
dbo.PURCHASESORDERBOM.Reqision
FROM dbo.PURCHASESORDERBOM INNER JOIN
dbo.ITEM ON dbo.PURCHASESORDERBOM.ITEMCODE = dbo.ITEM.ITEMCODE INNER JOIN
dbo.PURCHASESORDER ON dbo.PURCHASESORDERBOM.CINVNO = dbo.PURCHASESORDER.CINVNO INNER JOIN
dbo.LEDGER ON dbo.PURCHASESORDER.LEDGERCODE = dbo.LEDGER.LEDGERCODE
export data into worl exel pdf
protected void Button2_Click(object sender, EventArgs e)
{
Response.Write("<script>window.close()</script>");
}
protected void Button3_Click(object sender, EventArgs e)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView2.AllowPaging = false;
GridView2.DataBind();
GridView2.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
}
protected void Button4_Click(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.XLS");
Response.Charset = "";
Response.ContentType = "application/vnd.XLS";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView2.AllowPaging = false;
GridView2.DataBind();
GridView2.RenderControl(hw);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
/* Verifies that the control is rendered */
}
{
Response.Write("<script>window.close()</script>");
}
protected void Button3_Click(object sender, EventArgs e)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView2.AllowPaging = false;
GridView2.DataBind();
GridView2.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
}
protected void Button4_Click(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.XLS");
Response.Charset = "";
Response.ContentType = "application/vnd.XLS";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView2.AllowPaging = false;
GridView2.DataBind();
GridView2.RenderControl(hw);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
/* Verifies that the control is rendered */
}
MODEL POP UP
<style type="text/css">
.modalBackground
{
background-color: Gray;
filter: alpha(opacity=80);
z-index: 10000;
}
</style>
.modalBackground
{
background-color: Gray;
filter: alpha(opacity=80);
z-index: 10000;
}
</style>
<asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnShowPopup"
PopupControlID="pnlpopup" CancelControlID="btnCancel" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:Panel ID="pnlpopup" runat="server" BackColor="White" Height="100px" Width="450px"
Style="display: none">
<table width="100%" style="border: Solid 2px #D55500; width: 100%; height: 100%;
font-family: Arial; font-size: 12px" cellpadding="0" cellspacing="0">
<tr>
<td>
GatePass
</td>
<td>
<asp:TextBox ID="txtGatePass" runat="server"></asp:TextBox>
</td>
<td>
VichalPass
</td>
<td>
<asp:TextBox ID="txtVichalNo" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Arrivel Time
</td>
<td>
<asp:TextBox ID="txtArrtime" runat="server"></asp:TextBox>
</td>
<td>
Remarks
</td>
<td>
<asp:TextBox ID="txtre" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="4">
<center>
<asp:Button ID="btnUpdate" runat="server" CommandName="Update" Text="Ok" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</center>
</td>
</tr>
</table>
</asp:Panel>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnShowPopup"
PopupControlID="pnlpopup" CancelControlID="btnCancel" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:Panel ID="pnlpopup" runat="server" BackColor="White" Height="100px" Width="450px"
Style="display: none">
<table width="100%" style="border: Solid 2px #D55500; width: 100%; height: 100%;
font-family: Arial; font-size: 12px" cellpadding="0" cellspacing="0">
<tr>
<td>
GatePass
</td>
<td>
<asp:TextBox ID="txtGatePass" runat="server"></asp:TextBox>
</td>
<td>
VichalPass
</td>
<td>
<asp:TextBox ID="txtVichalNo" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Arrivel Time
</td>
<td>
<asp:TextBox ID="txtArrtime" runat="server"></asp:TextBox>
</td>
<td>
Remarks
</td>
<td>
<asp:TextBox ID="txtre" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="4">
<center>
<asp:Button ID="btnUpdate" runat="server" CommandName="Update" Text="Ok" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</center>
</td>
</tr>
</table>
</asp:Panel>
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Challan No.</asp:LinkButton>
protected void LinkButton1_Click(object sender, EventArgs e)
{
this.ModalPopupExtender1.Show();
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
this.ModalPopupExtender1.Show();
}
E-MAIL SENDING
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;
/// <summary>
/// Summary description for mailsending
/// </summary>
public class mailsending
{
public mailsending()
{ //
// TODO: Add constructor logic here
//
}
public void send(string clintmailto, string mess)
{
MailMessage mail = new MailMessage();
mail.To.Add(new MailAddress(clintmailto));
mail.From = new MailAddress("anil@ABC.com");
mail.Subject = "welcome to deltaesolution";
//mail.Body = txtQuery.Text;
mail.Body =mess;
mail.IsBodyHtml = true;
mail.Priority = MailPriority.Normal;
SmtpClient mailclient = new SmtpClient("mail.ABC.com");
mailclient.Credentials = new System.Net.NetworkCredential("mail@ABC.com", "Admin123");
mailclient.Send(mail);
}
}
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;
/// <summary>
/// Summary description for mailsending
/// </summary>
public class mailsending
{
public mailsending()
{ //
// TODO: Add constructor logic here
//
}
public void send(string clintmailto, string mess)
{
MailMessage mail = new MailMessage();
mail.To.Add(new MailAddress(clintmailto));
mail.From = new MailAddress("anil@ABC.com");
mail.Subject = "welcome to deltaesolution";
//mail.Body = txtQuery.Text;
mail.Body =mess;
mail.IsBodyHtml = true;
mail.Priority = MailPriority.Normal;
SmtpClient mailclient = new SmtpClient("mail.ABC.com");
mailclient.Credentials = new System.Net.NetworkCredential("mail@ABC.com", "Admin123");
mailclient.Send(mail);
}
}
WEB CONFIG CONNECTION STRING SET:
<appSettings>
<add key="strLocalCon" value="Data Source=ABC\SQLEXPRESS;Initial Catalog=ABC;Integrated Security=True"/>
</appSettings>
<connectionStrings>
<add name="conn" connectionString="Data Source=ABC\SQLEXPRESS;Initial Catalog=ABC;Integrated Security=True"/>
</connectionStrings>
USE:
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["conn"].ToString());
<add key="strLocalCon" value="Data Source=ABC\SQLEXPRESS;Initial Catalog=ABC;Integrated Security=True"/>
</appSettings>
<connectionStrings>
<add name="conn" connectionString="Data Source=ABC\SQLEXPRESS;Initial Catalog=ABC;Integrated Security=True"/>
</connectionStrings>
USE:
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["conn"].ToString());
MESSAGE BOX CLASS
public void MessageBox(System.Web.UI.Page page, string Msg)
{
string MsgScript = "<script language='javascript'>alert('" + Msg + "')</script>";
if (!(page.IsStartupScriptRegistered("MessageScript")))
page.RegisterStartupScript("MessageScript", MsgScript);
}
USE:
MessageBox(this, "Try Again");
{
string MsgScript = "<script language='javascript'>alert('" + Msg + "')</script>";
if (!(page.IsStartupScriptRegistered("MessageScript")))
page.RegisterStartupScript("MessageScript", MsgScript);
}
USE:
MessageBox(this, "Try Again");
PRINTIG WITH ERDLC
CREATE RDLC REPORT FIRST USING DATASET
.ASPX
<center>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
Font-Size="8pt" Height="400px" Width="825px">
<LocalReport ReportPath="PrintRequestion.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1"
Name="RequestionPrint_printrequestion" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetData"
TypeName="RequestionPrintTableAdapters.printrequestionTableAdapter">
</asp:ObjectDataSource>
</center>
.CS
public void princhallan()
{
try
{
string namep = objcom.porjectname();
string firmname = objcom.firmname();
string aa = "select ITEMNAME,Qty,UNITNAME from printrequestion where Mvoucher=" + Request.QueryString["id"].ToString() + "";
DataSet ds = SqlHelper.ExecuteDataset(con, CommandType.Text, aa);
string date = "A";
string ddate = "a";
string narration = "a";
string worktime = "a";
string Name = "a";
string aa2 = "select * from printrequestion where Mvoucher=" + Request.QueryString["id"].ToString() + "";
SqlDataReader rd = SqlHelper.ExecuteReader(con, CommandType.Text, aa2);
if (rd.Read())
{
date = rd["Date"].ToString();
date = Convert.ToDateTime(date).ToString("dd/MM/yyyy");
ddate = rd["DelDate"].ToString();
ddate = Convert.ToDateTime(ddate).ToString("dd/MM/yyyy");
narration = rd["Remarks"].ToString();
worktime = rd["Worktime"].ToString();
Name = rd["Name"].ToString();
rd.Close();
}
ReportParameter[] param = new ReportParameter[9];
param[0] = new ReportParameter("Report_Parameter_0", firmname);
param[1] = new ReportParameter("Report_Parameter_1", System.DateTime.Now.ToString("dd/MM/yyyy"));
param[2] = new ReportParameter("Report_Parameter_2", namep);
param[3] = new ReportParameter("Report_Parameter_3", Request.QueryString["id"].ToString());
param[4] = new ReportParameter("Report_Parameter_4", date);
param[5] = new ReportParameter("Report_Parameter_5", ddate);
param[6] = new ReportParameter("Report_Parameter_6", narration);
param[7] = new ReportParameter("Report_Parameter_7", worktime);
param[8] = new ReportParameter("Report_Parameter_8", Name);
ReportViewer1.LocalReport.SetParameters(param);
ReportViewer1.LocalReport.DataSources.Clear();
ReportDataSource reportDSHeader = new ReportDataSource("RequestionPrint_printrequestion", ds.Tables[0]);
ReportViewer1.LocalReport.DataSources.Add(reportDSHeader);
ReportViewer1.LocalReport.Refresh();
}
catch (Exception ex)
{
MessageBox(this, "Try Again");
}
finally { }
}
.ASPX
<center>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
Font-Size="8pt" Height="400px" Width="825px">
<LocalReport ReportPath="PrintRequestion.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1"
Name="RequestionPrint_printrequestion" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetData"
TypeName="RequestionPrintTableAdapters.printrequestionTableAdapter">
</asp:ObjectDataSource>
</center>
.CS
public void princhallan()
{
try
{
string namep = objcom.porjectname();
string firmname = objcom.firmname();
string aa = "select ITEMNAME,Qty,UNITNAME from printrequestion where Mvoucher=" + Request.QueryString["id"].ToString() + "";
DataSet ds = SqlHelper.ExecuteDataset(con, CommandType.Text, aa);
string date = "A";
string ddate = "a";
string narration = "a";
string worktime = "a";
string Name = "a";
string aa2 = "select * from printrequestion where Mvoucher=" + Request.QueryString["id"].ToString() + "";
SqlDataReader rd = SqlHelper.ExecuteReader(con, CommandType.Text, aa2);
if (rd.Read())
{
date = rd["Date"].ToString();
date = Convert.ToDateTime(date).ToString("dd/MM/yyyy");
ddate = rd["DelDate"].ToString();
ddate = Convert.ToDateTime(ddate).ToString("dd/MM/yyyy");
narration = rd["Remarks"].ToString();
worktime = rd["Worktime"].ToString();
Name = rd["Name"].ToString();
rd.Close();
}
ReportParameter[] param = new ReportParameter[9];
param[0] = new ReportParameter("Report_Parameter_0", firmname);
param[1] = new ReportParameter("Report_Parameter_1", System.DateTime.Now.ToString("dd/MM/yyyy"));
param[2] = new ReportParameter("Report_Parameter_2", namep);
param[3] = new ReportParameter("Report_Parameter_3", Request.QueryString["id"].ToString());
param[4] = new ReportParameter("Report_Parameter_4", date);
param[5] = new ReportParameter("Report_Parameter_5", ddate);
param[6] = new ReportParameter("Report_Parameter_6", narration);
param[7] = new ReportParameter("Report_Parameter_7", worktime);
param[8] = new ReportParameter("Report_Parameter_8", Name);
ReportViewer1.LocalReport.SetParameters(param);
ReportViewer1.LocalReport.DataSources.Clear();
ReportDataSource reportDSHeader = new ReportDataSource("RequestionPrint_printrequestion", ds.Tables[0]);
ReportViewer1.LocalReport.DataSources.Add(reportDSHeader);
ReportViewer1.LocalReport.Refresh();
}
catch (Exception ex)
{
MessageBox(this, "Try Again");
}
finally { }
}
WORKING WITH DATA TABLE
.CS
public DataTable CreateDataTable()
{
DataTable myDataTable = new DataTable();
DataColumn myDataColumn;
DataColumn auto = new DataColumn("AutoID", typeof(System.Int32));
myDataTable.Columns.Add(auto);
auto.AutoIncrement = true;
auto.AutoIncrementSeed = 1;
auto.ReadOnly = true;
auto.Unique = true;
DataColumn[] keys = new DataColumn[1];
keys[0] = auto;
myDataTable.PrimaryKey = keys;
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "Date";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "Name Of Supply";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "Code Of Supply";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "DeliveryDate";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "Remark";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "ItemName";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "ItemCode";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "ReqQty";
myDataTable.Columns.Add(myDataColumn);
return myDataTable;
}
public void AddDataToTable(string Date, string DeliveryDate, string Remark, string ItemName, string ItemCode, string ReqQty, DataTable myTable)
{
DataRow row;
row = myTable.NewRow();
row["Date"] = Date;
row["DeliveryDate"] = DeliveryDate;
row["Remark"] = Remark;
row["ItemName"] = ItemName;
row["ItemCode"] = ItemCode;
row["ReqQty"] = ReqQty;
myTable.Rows.Add(row);
}
.ASPX
if (!Page.IsPostBack)
{
DataTable myDt = new DataTable();
myDt = objrequest.CreateDataTable();
Session["myDatatable"] = myDt;
GridView1.DataSource = ((DataTable)Session["myDatatable"]).DefaultView;
GridView1.DataBind();
}
public void fiidataingrid1()
{
objrequest.AddDataToTable(this.txtDate.Text, this.txtDD.Text, this.txtRemarkes.Text, ddliname.SelectedItem.Text, this.ddliname.SelectedItem.Value, this.txtReqQuantity.Text, (DataTable)Session["myDatatable"]);
}
public void fiidataingrid()
{
if (Session["myDatatable"] != null)
{
DataTable dt = (DataTable)Session["myDatatable"];
if ((dt != null) && (dt.Rows.Count > 0))
{
GridView1.Visible = true;
GridView1.DataSource = ((DataTable)Session["myDatatable"]).DefaultView;
GridView1.DataBind();
}
else
{
GridView1.Visible = false;
}
}
}
EDIT/UPDATE/DELETE/DATABOUND
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
fiidataingrid();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
DataTable mydt = (DataTable)Session["myDatatable"];
DataRow dr = mydt.Rows[e.RowIndex];
mydt.Rows.Remove(dr);
GridView1.EditIndex = -1;
if (mydt.Rows.Count > 0)
{
fiidataingrid();
}
else
{
pnlFixed.Enabled = true;
btnSave.Enabled = false;
fiidataingrid();
}
}
protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
{
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
fiidataingrid();
}
protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox txt4 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtrqty1");
DropDownList dd1 = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("Ddliname");
// DropDownList dd1 = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("Ddliname");
string newtxt4 = txt4.Text.ToString();
string newtxt5 = dd1.SelectedValue.ToString();
string newtxt6 = dd1.SelectedItem.ToString();
DataTable dt = (DataTable)Session["myDatatable"];
DataRow dr = dt.Rows[e.RowIndex];
dr["ReqQty"] = newtxt4;
dr["ItemName"] = newtxt6;
dr["ITEMCODE"] = newtxt5;
dr.AcceptChanges();
Session["myDatatable"] = dt;
GridView1.EditIndex = -1;
fiidataingrid();
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
Label lableTemp = (Label)e.Row.FindControl("lblsetitem");
DropDownList ddlTemp = (DropDownList)e.Row.FindControl("Ddliname");
DataSet ds = RealStateClass.Requestpage.fillitem();
ddlTemp.DataSource = ds;
ddlTemp.DataTextField = "itemNAME";
ddlTemp.DataValueField = "ITEMCODE";
ddlTemp.Text = lableTemp.Text;
ddlTemp.DataBind();
}
}
}
public DataTable CreateDataTable()
{
DataTable myDataTable = new DataTable();
DataColumn myDataColumn;
DataColumn auto = new DataColumn("AutoID", typeof(System.Int32));
myDataTable.Columns.Add(auto);
auto.AutoIncrement = true;
auto.AutoIncrementSeed = 1;
auto.ReadOnly = true;
auto.Unique = true;
DataColumn[] keys = new DataColumn[1];
keys[0] = auto;
myDataTable.PrimaryKey = keys;
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "Date";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "Name Of Supply";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "Code Of Supply";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "DeliveryDate";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "Remark";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "ItemName";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "ItemCode";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "ReqQty";
myDataTable.Columns.Add(myDataColumn);
return myDataTable;
}
public void AddDataToTable(string Date, string DeliveryDate, string Remark, string ItemName, string ItemCode, string ReqQty, DataTable myTable)
{
DataRow row;
row = myTable.NewRow();
row["Date"] = Date;
row["DeliveryDate"] = DeliveryDate;
row["Remark"] = Remark;
row["ItemName"] = ItemName;
row["ItemCode"] = ItemCode;
row["ReqQty"] = ReqQty;
myTable.Rows.Add(row);
}
.ASPX
if (!Page.IsPostBack)
{
DataTable myDt = new DataTable();
myDt = objrequest.CreateDataTable();
Session["myDatatable"] = myDt;
GridView1.DataSource = ((DataTable)Session["myDatatable"]).DefaultView;
GridView1.DataBind();
}
public void fiidataingrid1()
{
objrequest.AddDataToTable(this.txtDate.Text, this.txtDD.Text, this.txtRemarkes.Text, ddliname.SelectedItem.Text, this.ddliname.SelectedItem.Value, this.txtReqQuantity.Text, (DataTable)Session["myDatatable"]);
}
public void fiidataingrid()
{
if (Session["myDatatable"] != null)
{
DataTable dt = (DataTable)Session["myDatatable"];
if ((dt != null) && (dt.Rows.Count > 0))
{
GridView1.Visible = true;
GridView1.DataSource = ((DataTable)Session["myDatatable"]).DefaultView;
GridView1.DataBind();
}
else
{
GridView1.Visible = false;
}
}
}
EDIT/UPDATE/DELETE/DATABOUND
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
fiidataingrid();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
DataTable mydt = (DataTable)Session["myDatatable"];
DataRow dr = mydt.Rows[e.RowIndex];
mydt.Rows.Remove(dr);
GridView1.EditIndex = -1;
if (mydt.Rows.Count > 0)
{
fiidataingrid();
}
else
{
pnlFixed.Enabled = true;
btnSave.Enabled = false;
fiidataingrid();
}
}
protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
{
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
fiidataingrid();
}
protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox txt4 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtrqty1");
DropDownList dd1 = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("Ddliname");
// DropDownList dd1 = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("Ddliname");
string newtxt4 = txt4.Text.ToString();
string newtxt5 = dd1.SelectedValue.ToString();
string newtxt6 = dd1.SelectedItem.ToString();
DataTable dt = (DataTable)Session["myDatatable"];
DataRow dr = dt.Rows[e.RowIndex];
dr["ReqQty"] = newtxt4;
dr["ItemName"] = newtxt6;
dr["ITEMCODE"] = newtxt5;
dr.AcceptChanges();
Session["myDatatable"] = dt;
GridView1.EditIndex = -1;
fiidataingrid();
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
Label lableTemp = (Label)e.Row.FindControl("lblsetitem");
DropDownList ddlTemp = (DropDownList)e.Row.FindControl("Ddliname");
DataSet ds = RealStateClass.Requestpage.fillitem();
ddlTemp.DataSource = ds;
ddlTemp.DataTextField = "itemNAME";
ddlTemp.DataValueField = "ITEMCODE";
ddlTemp.Text = lableTemp.Text;
ddlTemp.DataBind();
}
}
}
GRID VIEW EDITING
<asp:GridView ID="gvModification" runat="server" EmptyDataText="No Record" AutoGenerateColumns="False"
DataKeyNames="id" OnRowCancelingEdit="gvModification_RowCancelingEdit" OnRowCommand="gvModification_RowCommand"
OnRowDataBound="gvModification_RowDataBound" OnRowDeleting="gvModification_RowDeleting"
OnRowEditing="gvModification_RowEditing" OnRowUpdating="gvModification_RowUpdating"
Style="font-family: Arial, Helvetica, sans-serif; font-size: small" Width="100%"
CellPadding="4" ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:TemplateField HeaderText="Date">
<ItemTemplate>
<asp:Label ID="lblDate" runat="server" Text='<%# Eval("DATE")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtDate" Width="150" runat="server" Text='<%# Eval("DATE") %>'></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" Format="dd/MM/yyyy" runat="server" TargetControlID="txtDate">
</cc1:CalendarExtender>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ITEM">
<ItemTemplate>
<asp:Label ID="lblItem" runat="server" Text='<%# Eval("ItemName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlItem" runat="server" DataSourceID="SqlDataSource1" SelectedValue='<%# Bind("ITEMCODE") %>'
DataTextField="ITEMNAME" DataValueField="ITEMCODE">
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="hnfItemCode" runat="server" Value='<%#Eval("Itemcode") %>' Visible="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:Label ID="lblQty" runat="server" Text='<%# Eval("Qty") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtQty" Width="50" runat="server" Text='<%# Eval("Qty") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="hnChallan" runat="server" Value='<%# Eval("mvoucher") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbEdit" runat="server" CommandName="Edit" Text="Edit">
</asp:LinkButton>
<asp:LinkButton ID="lbDelete" runat="server" CommandArgument='<%#Bind("ID") %>' CommandName="Delete"
Text="Delete"></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="lbUpdate" runat="server" CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton ID="lbCancel" runat="server" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" CssClass="grd" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
c#
protected void gvModification_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
int id = Convert.ToInt32(e.CommandArgument);
objrequest.id = id.ToString();
objrequest.delrecord1();
Page.ClientScript.RegisterStartupScript(typeof(Page), "Deleted", "alert('Deleted ')", true);
modification();
try
{
if (gvModification.Rows.Count <= 0)
{
objrequest.updatehead();
DataSet ds = RealStateClass.Requestpage.getrerqestion(txtrequestNo.Text.ToString());
if (ds.Tables[0].Rows.Count > 0)
{ }
else
{
objrequest.CINVNO = txtrequestNo.Text.ToString();
objrequest.delrecord2();
}
}
}
catch (Exception) { }
finally { }
}
}
protected void gvModification_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
}
protected void gvModification_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string st1 = ((TextBox)gvModification.Rows[e.RowIndex].Cells[0].FindControl("txtDate")).Text;
string st2 = ((DropDownList)gvModification.Rows[e.RowIndex].Cells[2].FindControl("ddlItem")).SelectedItem.Value;
string st3 = ((TextBox)gvModification.Rows[e.RowIndex].Cells[1].FindControl("txtQty")).Text;
string st4 = ((HiddenField)gvModification.Rows[e.RowIndex].Cells[3].FindControl("hnChallan")).Value;
DateTime dt2;
dt2 = Convert.ToDateTime(st1, System.Globalization.CultureInfo.CreateSpecificCulture("en-CA"));
objrequest.Date = dt2;
objrequest.ItemCode = st2.ToString();
objrequest.Quantity = st3.ToString();
objrequest.id = gvModification.DataKeys[e.RowIndex].Values["id"].ToString();
objrequest.updaterequestmodi();
gvModification.EditIndex = -1;
modification();
}
protected void gvModification_RowDataBound(object sender, GridViewRowEventArgs e)
{
}
protected void gvModification_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gvModification.EditIndex = -1;
modification();
}
protected void gvModification_RowEditing(object sender, GridViewEditEventArgs e)
{
gvModification.EditIndex = e.NewEditIndex;
modification();
}
DataKeyNames="id" OnRowCancelingEdit="gvModification_RowCancelingEdit" OnRowCommand="gvModification_RowCommand"
OnRowDataBound="gvModification_RowDataBound" OnRowDeleting="gvModification_RowDeleting"
OnRowEditing="gvModification_RowEditing" OnRowUpdating="gvModification_RowUpdating"
Style="font-family: Arial, Helvetica, sans-serif; font-size: small" Width="100%"
CellPadding="4" ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:TemplateField HeaderText="Date">
<ItemTemplate>
<asp:Label ID="lblDate" runat="server" Text='<%# Eval("DATE")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtDate" Width="150" runat="server" Text='<%# Eval("DATE") %>'></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" Format="dd/MM/yyyy" runat="server" TargetControlID="txtDate">
</cc1:CalendarExtender>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ITEM">
<ItemTemplate>
<asp:Label ID="lblItem" runat="server" Text='<%# Eval("ItemName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlItem" runat="server" DataSourceID="SqlDataSource1" SelectedValue='<%# Bind("ITEMCODE") %>'
DataTextField="ITEMNAME" DataValueField="ITEMCODE">
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="hnfItemCode" runat="server" Value='<%#Eval("Itemcode") %>' Visible="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:Label ID="lblQty" runat="server" Text='<%# Eval("Qty") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtQty" Width="50" runat="server" Text='<%# Eval("Qty") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="hnChallan" runat="server" Value='<%# Eval("mvoucher") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbEdit" runat="server" CommandName="Edit" Text="Edit">
</asp:LinkButton>
<asp:LinkButton ID="lbDelete" runat="server" CommandArgument='<%#Bind("ID") %>' CommandName="Delete"
Text="Delete"></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="lbUpdate" runat="server" CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton ID="lbCancel" runat="server" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" CssClass="grd" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
c#
protected void gvModification_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
int id = Convert.ToInt32(e.CommandArgument);
objrequest.id = id.ToString();
objrequest.delrecord1();
Page.ClientScript.RegisterStartupScript(typeof(Page), "Deleted", "alert('Deleted ')", true);
modification();
try
{
if (gvModification.Rows.Count <= 0)
{
objrequest.updatehead();
DataSet ds = RealStateClass.Requestpage.getrerqestion(txtrequestNo.Text.ToString());
if (ds.Tables[0].Rows.Count > 0)
{ }
else
{
objrequest.CINVNO = txtrequestNo.Text.ToString();
objrequest.delrecord2();
}
}
}
catch (Exception) { }
finally { }
}
}
protected void gvModification_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
}
protected void gvModification_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string st1 = ((TextBox)gvModification.Rows[e.RowIndex].Cells[0].FindControl("txtDate")).Text;
string st2 = ((DropDownList)gvModification.Rows[e.RowIndex].Cells[2].FindControl("ddlItem")).SelectedItem.Value;
string st3 = ((TextBox)gvModification.Rows[e.RowIndex].Cells[1].FindControl("txtQty")).Text;
string st4 = ((HiddenField)gvModification.Rows[e.RowIndex].Cells[3].FindControl("hnChallan")).Value;
DateTime dt2;
dt2 = Convert.ToDateTime(st1, System.Globalization.CultureInfo.CreateSpecificCulture("en-CA"));
objrequest.Date = dt2;
objrequest.ItemCode = st2.ToString();
objrequest.Quantity = st3.ToString();
objrequest.id = gvModification.DataKeys[e.RowIndex].Values["id"].ToString();
objrequest.updaterequestmodi();
gvModification.EditIndex = -1;
modification();
}
protected void gvModification_RowDataBound(object sender, GridViewRowEventArgs e)
{
}
protected void gvModification_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gvModification.EditIndex = -1;
modification();
}
protected void gvModification_RowEditing(object sender, GridViewEditEventArgs e)
{
gvModification.EditIndex = e.NewEditIndex;
modification();
}
Subscribe to:
Posts (Atom)