private void SampleJaggedArray()
{
int[][] jaggedArray;
jaggedArray = new int[2][];
jaggedArray[0] = new int[3];
jaggedArray[1] = new int[6];
jaggedArray[0][0] = 1; jaggedArray[0][1] = 2; jaggedArray[0][2] = 3;
jaggedArray[1][0] = 1; jaggedArray[1][1] = 2; jaggedArray[1][2] = 3;
jaggedArray[1][3] = 4; jaggedArray[1][4] = 5; jaggedArray[1][5] = 6;
for (int i = 0; i < jaggedArray.GetLength(0); i++)
{
Console.Write("jaggedArray[" + i + "] :\t");
for (int j = 0; j < jaggedArray[i].Length; j++)
{
Console.Write(jaggedArray[i][j] + "\t");
}
Console.WriteLine();
}
}
Monday, May 12, 2008
binding DataTable to asp:Repeater
html code :
<asp:Repeater id="Repeater1" runat="server">
<HeaderTemplate>
<table width="100%" border="0" cellspacing="0">
<tr><td colspan="2"><b>Personal Database</b></td></tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="background-color:inherit;" colspan="2"> <%# DataBinder.Eval(Container, "DataItem.Name") %> </td>
</tr>
<tr>
<td> <%# DataBinder.Eval(Container, "DataItem.Age") %>
</td>
<td> <%# DataBinder.Eval(Container, "DataItem.Designation") %>
</td>
</tr>
<tr>
<td>
<a href="<%# DataBinder.Eval(Container, "DataItem.Email") %>">
<%# DataBinder.Eval(Container, "DataItem.Email") %>
</a>
</td>
</tr>
</ItemTemplate>
<SeparatorTemplate>
<tr>
<td height="2" colspan="2"><hr /></td>
</tr>
</SeparatorTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
code-behind :
public partial class DetailsPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable("Personal Database");
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Age", typeof(Int32));
dt.Columns.Add("Designation", typeof(string));
dt.Columns.Add("Email", typeof(string));
dt.Rows.Add(new string[4] { "Jack", 24, ".net Programmer", "jackdsouza0@gmail.com" });
dt.Rows.Add(new string[4] { "Jill", 23, ".net Programmer", "jilldsouza0@gmail.com" });
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
}
<asp:Repeater id="Repeater1" runat="server">
<HeaderTemplate>
<table width="100%" border="0" cellspacing="0">
<tr><td colspan="2"><b>Personal Database</b></td></tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="background-color:inherit;" colspan="2"> <%# DataBinder.Eval(Container, "DataItem.Name") %> </td>
</tr>
<tr>
<td> <%# DataBinder.Eval(Container, "DataItem.Age") %>
</td>
<td> <%# DataBinder.Eval(Container, "DataItem.Designation") %>
</td>
</tr>
<tr>
<td>
<a href="<%# DataBinder.Eval(Container, "DataItem.Email") %>">
<%# DataBinder.Eval(Container, "DataItem.Email") %>
</a>
</td>
</tr>
</ItemTemplate>
<SeparatorTemplate>
<tr>
<td height="2" colspan="2"><hr /></td>
</tr>
</SeparatorTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
code-behind :
public partial class DetailsPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable("Personal Database");
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Age", typeof(Int32));
dt.Columns.Add("Designation", typeof(string));
dt.Columns.Add("Email", typeof(string));
dt.Rows.Add(new string[4] { "Jack", 24, ".net Programmer", "jackdsouza0@gmail.com" });
dt.Rows.Add(new string[4] { "Jill", 23, ".net Programmer", "jilldsouza0@gmail.com" });
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
}
Monday, September 10, 2007
a good site for C#.Net
I have found out one very nice web site to start off with C# .Net. Those who are willing to learn the basics of C# .Net, this site would help you a lot.
Check it out
http://www.functionx.com/vcsharp/Lesson01.htm
Check it out
http://www.functionx.com/vcsharp/Lesson01.htm
Tuesday, September 4, 2007
Reading CD Rom in C# .NEt
One of my friends had a trouble in Reading data from the CD. Here is a simple solution which i found out.
In this code, we first find out the Logical Drives which are read only. Once we get all read only drives. We can find out the files from CD which is in CD rom. (Not sure whether it will work with CD Writers).But here is the code, u can use ths code for some other thing. And if u have any other solution for this,you are welcome.
private void ReadData(object sender, EventArgs e)
{
string[] drivesPathTab=Directory.GetLogicalDrives();
for (int i = 0; i < drivesPathTab.Length; i++)
{
DirectoryInfo dirInfo = new DirectoryInfo(drivesPathTab[i]);
if ((dirInfo.Attributes & FileAttributes.ReadOnly) != 0)
{
// if code enters in this block, then drive is Read only
// Check for the file on the drive, If it exists, continue.
}
}
}
In this code, we first find out the Logical Drives which are read only. Once we get all read only drives. We can find out the files from CD which is in CD rom. (Not sure whether it will work with CD Writers).But here is the code, u can use ths code for some other thing. And if u have any other solution for this,you are welcome.
private void ReadData(object sender, EventArgs e)
{
string[] drivesPathTab=Directory.GetLogicalDrives();
for (int i = 0; i < drivesPathTab.Length; i++)
{
DirectoryInfo dirInfo = new DirectoryInfo(drivesPathTab[i]);
if ((dirInfo.Attributes & FileAttributes.ReadOnly) != 0)
{
// if code enters in this block, then drive is Read only
// Check for the file on the drive, If it exists, continue.
}
}
}
Friday, August 31, 2007
Windows Presentation Foundation Samples from MSDN
Windows Presentation Foundation Samples
The Windows Presentation Foundation (WPF) samples are divided into two categories: Application samples and Technology samples.
Application samples are end-to-end applications that demonstrate multiple platform features. These samples are intended to show real world usage scenarios, and are an effective way to see the breadth of WPF.
Technology samples are targeted to a specific technology area, such as Controls or Animation. These samples demonstrate specific usage scenarios or features, and are generally not end-to-end applications.
Here is the Link :
http://msdn2.microsoft.com/en-us/library/ms771633.aspx
The Windows Presentation Foundation (WPF) samples are divided into two categories: Application samples and Technology samples.
Application samples are end-to-end applications that demonstrate multiple platform features. These samples are intended to show real world usage scenarios, and are an effective way to see the breadth of WPF.
Technology samples are targeted to a specific technology area, such as Controls or Animation. These samples demonstrate specific usage scenarios or features, and are generally not end-to-end applications.
Here is the Link :
http://msdn2.microsoft.com/en-us/library/ms771633.aspx
Thursday, August 30, 2007
IValueConverter sample
This sample will show you how to use IValueConverter in WPF. It is very handy and very impt concept.Dont miss it.
Here we will populate the DataTable and bind it to the DataContext of the ListView
Now go to XAML and use Styles and triggers to implement our logic of Age as shown below:
Now to support Static Resource ValueConv which we have used above in Style, Create a class which implements IValueConerteras shown below
Nice example to know about 3D in WPF
This is a nice sample to learn basic on 3D. i found this one in msdn. I think anyone interested in 3d designing shud refere to this link :
http://msdn2.microsoft.com/en-us/library/ms752082.aspx
http://msdn2.microsoft.com/en-us/library/ms752082.aspx
Subscribe to:
Posts (Atom)