//DefaultView:filter a limited number of columns from a table:
//Distinct Data in DataTable with the Field of roleid,roleName,abbreviation........
DataSet infoDS=new DataSet();
DataTable dTable = infoDS.Tables[0].DefaultView.ToTable(true, "roleid", "roleName", "abbreviation");
for (int i = 0; i < dTable.Rows.Count; i++)
{
if (dTable.Rows.Count > 0)
{
string _RoleId = dTable.Rows[i]["roleid"].ToString();
string _RoleName = dTable.Rows[i]["roleName"].ToString();
string _Abbreviation = dTable.Rows[i]["abbreviation"].ToString();
}
}
Tuesday, January 11, 2011
Compute with DataTable
DataTable Dtable=new DataTable();
DataColumn DColumn=new DataColumn("Salary",typeof(float));
DTable.Column.Add(DColumn);
DataRow DRow=DTable.NewRow();
DRow[0]=25000;
DTable.Rows.Add(DRow);
DRow=DTable.NewRow();
DRow[0]=30000;
DTable.Rows.Add(DRow);
float TotalSalary=(float)DTable.Compute("Sum(Salary)","");
Console.WriteLine(TotalSalary);
DataColumn DColumn=new DataColumn("Salary",typeof(float));
DTable.Column.Add(DColumn);
DataRow DRow=DTable.NewRow();
DRow[0]=25000;
DTable.Rows.Add(DRow);
DRow=DTable.NewRow();
DRow[0]=30000;
DTable.Rows.Add(DRow);
float TotalSalary=(float)DTable.Compute("Sum(Salary)","");
Console.WriteLine(TotalSalary);
Labels:
Compute with DataTable
Saturday, January 8, 2011
Dropdown bind through xml
XmlDocument xml = new XmlDocument();
string s =Server.MapPath("XMLfILE.xml");
string list = "/catalog/book";
xml.Load(s);
XmlNodeList xn = xml.SelectNodes(list);
foreach (XmlNode eleSourceNode in xn)
{
string ID = eleSourceNode.Attributes["id"].Value;
string author1 = eleSourceNode["author"].InnerText;
DRPLIST.Items.Add(new ListItem(author1 ,ID));
}
//XMLFILE.xml
?xml version="1.0"?>
catalog>
book id="bk101">
author>Gambardella, Matthew /author>
title>XML Developer's Guide /title>
genre>Computer /genre>
price>44.95 /price>
publish_date>2000-10-01 /publish_date>
description>
An in-depth look at creating applications
with XML.
/description>
/book>
book id="bk111">
author>O'Brien, Tim /author>
title>MSXML3: A Comprehensive Guide /title>
genre>Computer /genre>
price>36.95 /price>
publish_date>2000-12-01/publish_date>
description>
The Microsoft MSXML3 parser is covered in
detail, with attention to XML DOM interfaces, XSLT processing,
SAX and more.
/description>
/book>
book id="bk112">
author>Galos, Mike/author>
title>Visual Studio 7: A Comprehensive Guide/title>
genre>Computer /genre>
price>49.95 /price>
publish_date>2001-04-16/publish_date>
description>
Microsoft Visual Studio 7 is explored in depth,
looking at how Visual Basic, Visual C++, C#, and ASP+ are
integrated into a comprehensive development
environment.
/description>
/book>
/catalog>
string s =Server.MapPath("XMLfILE.xml");
string list = "/catalog/book";
xml.Load(s);
XmlNodeList xn = xml.SelectNodes(list);
foreach (XmlNode eleSourceNode in xn)
{
string ID = eleSourceNode.Attributes["id"].Value;
string author1 = eleSourceNode["author"].InnerText;
DRPLIST.Items.Add(new ListItem(author1 ,ID));
}
//XMLFILE.xml
?xml version="1.0"?>
catalog>
book id="bk101">
author>Gambardella, Matthew /author>
title>XML Developer's Guide /title>
genre>Computer /genre>
price>44.95 /price>
publish_date>2000-10-01 /publish_date>
description>
An in-depth look at creating applications
with XML.
/description>
/book>
book id="bk111">
author>O'Brien, Tim /author>
title>MSXML3: A Comprehensive Guide /title>
genre>Computer /genre>
price>36.95 /price>
publish_date>2000-12-01/publish_date>
description>
The Microsoft MSXML3 parser is covered in
detail, with attention to XML DOM interfaces, XSLT processing,
SAX and more.
/description>
/book>
book id="bk112">
author>Galos, Mike/author>
title>Visual Studio 7: A Comprehensive Guide/title>
genre>Computer /genre>
price>49.95 /price>
publish_date>2001-04-16/publish_date>
description>
Microsoft Visual Studio 7 is explored in depth,
looking at how Visual Basic, Visual C++, C#, and ASP+ are
integrated into a comprehensive development
environment.
/description>
/book>
/catalog>
Labels:
Dropdown bind through xml
Link for Asp.net Architecture(Isapi.dll,httpcontext,hpptmodule)
http://www.west-wind.com/presentations/howaspnetworks/howaspnetworks.asp
Boxing and Unboxing(Convert value type to ref type and ref type to value type.)
int Val = 1;
Object Obj = Val; //Boxing
int i = (int)Val; //Unboxing
Object Obj = Val; //Boxing
int i = (int)Val; //Unboxing
Wednesday, December 29, 2010
Send data through Post Method
///Where you use Post Method in page u have to set inside the web.cofig
and inside the system.web>--- pages enableViewStateMac="false">
//aspx Source page
form id="form1" method="post" action="http://localhost:1984/Test/get-posted-data.aspx" runat="server">
User : asp:TextBox ID="txtName" runat="server">/asp:TextBox>
Password : asp:TextBox ID="txtPassword" runat="server">/asp:TextBox>
asp:Button ID="btnSend" runat="server" Text="Send"/>
/form>
//Retrive value through Post Mehtod
// string[]s= Request.Form.AllKeys;//through this u can find all the value of post....
Response.Write("User : " + Request.Form["txtName"] + "
");
Response.Write("Password : " + Request.Form["txtPassword"] + "
");
and inside the system.web>--- pages enableViewStateMac="false">
//aspx Source page
form id="form1" method="post" action="http://localhost:1984/Test/get-posted-data.aspx" runat="server">
User : asp:TextBox ID="txtName" runat="server">/asp:TextBox>
Password : asp:TextBox ID="txtPassword" runat="server">/asp:TextBox>
asp:Button ID="btnSend" runat="server" Text="Send"/>
/form>
//Retrive value through Post Mehtod
// string[]s= Request.Form.AllKeys;//through this u can find all the value of post....
Response.Write("User : " + Request.Form["txtName"] + "
");
Response.Write("Password : " + Request.Form["txtPassword"] + "
");
Labels:
Send data through Post Method
Tuesday, December 28, 2010
Zip and Unzip the File(Through Ionic .Dll)
Download ionic.Dll from(http://dotnetzip.codeplex.com/releases/view/27890)
and Add the Dll through Add reference and Add the NameSpaces (using Ionic.Zip;)
ZipFile zip = new ZipFile();
// add this map file into the "images" directory in the zip archive
DirectoryInfo f = new DirectoryInfo("c:\\images");
FileInfo[] a = f.GetFiles();
for (int i = 0; i < a.Length; i++)
{
zip.AddFile("c:\\images\\" + a[i].Name, "images");
}
zip.Save("c:\\MyZipFile.zip");
String TargetDirectory = "c:\\MyZipFile.zip";
using (Ionic.Zip.ZipFile zip1 = Ionic.Zip.ZipFile.Read(TargetDirectory))
{
zip1.ExtractAll("c:\\UnZip",
Ionic.Zip.ExtractExistingFileAction.DoNotOverwrite);
}
and Add the Dll through Add reference and Add the NameSpaces (using Ionic.Zip;)
ZipFile zip = new ZipFile();
// add this map file into the "images" directory in the zip archive
DirectoryInfo f = new DirectoryInfo("c:\\images");
FileInfo[] a = f.GetFiles();
for (int i = 0; i < a.Length; i++)
{
zip.AddFile("c:\\images\\" + a[i].Name, "images");
}
zip.Save("c:\\MyZipFile.zip");
String TargetDirectory = "c:\\MyZipFile.zip";
using (Ionic.Zip.ZipFile zip1 = Ionic.Zip.ZipFile.Read(TargetDirectory))
{
zip1.ExtractAll("c:\\UnZip",
Ionic.Zip.ExtractExistingFileAction.DoNotOverwrite);
}
Subscribe to:
Posts (Atom)