CPS Does Blogging
Spirit of .NET
Sunday, October 31, 2010
New Start
it's almost 3 years from my last post :) i feel like blogging again.may be coz of a special request.I am still thinking i should continue this or not.May be i have a feeling that i may stop this again in near future.But I have to start.As i mention ,coz of a special request :) So where should i start ?
Wednesday, December 26, 2007
Tuesday, November 20, 2007
Visual Studio 2008 and .NET 3.5 Released
Yesterday(November 19, 2007) Microsoft has Released Visual Studio 2008 and .NET 3.5. You can download the final release using one of the links below :
you can download a 90-day free trial edition of Visual Studio 2008 Team Suite here. A 90-day free trial edition of Team Foundation Server can also be downloaded here.
Still they haven't announce about the trial of visual studio professional.
If you want to use the free Visual Studio 2008 Express editions (which are much smaller and totally free), you can download them here.
If you want to just install the .NET Framework 3.5 runtime, you can download it here.
And if you wanna know about more details about this please visit ScottGu's Blog
you can download a 90-day free trial edition of Visual Studio 2008 Team Suite here. A 90-day free trial edition of Team Foundation Server can also be downloaded here.
Still they haven't announce about the trial of visual studio professional.
If you want to use the free Visual Studio 2008 Express editions (which are much smaller and totally free), you can download them here.
If you want to just install the .NET Framework 3.5 runtime, you can download it here.
And if you wanna know about more details about this please visit ScottGu's Blog
Tuesday, August 07, 2007
Dynamic Template Columns in the ASP.NET 2.0 GridView Control: Part 2
Sorry for the delay. It's a bit late to publish the continuation of my earlier post. As I mentioned previously you can add a dynamic column to gridview. However there is another way of doing it. It depends on your requirement. The 2 nd method is much easier though.
You have to create a Usercontrol. Let's say you need to have a Text box in your grid. Then just add a text box to your Usercontrol and in HTML view you can edit it as shown below... (Other than a Textbox I have add a CompareValidator to check the data type of the Text box.)
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MyUserCont.ascx.cs" Inherits="TestApp_MyUserCont" %>
' Width="90px">
ID="CompareValidator1" runat="server" Display="Dynamic" Type="Currency" Operator="DataTypeCheck"
ErrorMessage="*" ControlToValidate="txtQty">
In the code Text='<%# Bind("Quantity") %>' take care of Binding data to the Text property of the Textbox. "Quantity" is the Column name of my data table (gridview data source).
Next is to create your Dynamic column as follows...
TemplateField tmpQty = new TemplateField();
tmpQty.HeaderText = "Quantity";
tmpQty.ItemTemplate = LoadTemplate("../TestApp/MyUserCont.ascx");
tmpQty.Visible = true;
gvTransaction.Columns.Add(tmpQty);
Hope this will make things easier than the earlier method. But there are some limitations. So as I mentioned earlier you have to identify which method is suitable according to your requirement.
You have to create a Usercontrol. Let's say you need to have a Text box in your grid. Then just add a text box to your Usercontrol and in HTML view you can edit it as shown below... (Other than a Textbox I have add a CompareValidator to check the data type of the Text box.)
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MyUserCont.ascx.cs" Inherits="TestApp_MyUserCont" %>
ID="CompareValidator1" runat="server" Display="Dynamic" Type="Currency" Operator="DataTypeCheck"
ErrorMessage="*" ControlToValidate="txtQty">
In the code Text='<%# Bind("Quantity") %>' take care of Binding data to the Text property of the Textbox. "Quantity" is the Column name of my data table (gridview data source).
Next is to create your Dynamic column as follows...
TemplateField tmpQty = new TemplateField();
tmpQty.HeaderText = "Quantity";
tmpQty.ItemTemplate = LoadTemplate("../TestApp/MyUserCont.ascx");
tmpQty.Visible = true;
gvTransaction.Columns.Add(tmpQty);
Hope this will make things easier than the earlier method. But there are some limitations. So as I mentioned earlier you have to identify which method is suitable according to your requirement.
Friday, August 03, 2007
Dynamic Template Columns in the ASP.NET 2.0 GridView Control: Part 1
Recently I was involved in a project where we needed to present the results of a database query as part of an ASP.NET application. It was such that the user can select grid columns and the type of the columns also Differentiating depending on the requirement. It may be a button, column, editable column (text box,check box,etc...) It was not known until runtime how many columns has to display, which columns has to display or which SQL query is needed to satisfy the search criteria. So I had to use dynamics template coloumns for the editable coloumns.
A GridView template is a class that implements the ITemplate interface. It defines the controls that will be displayed on the GridView in a column.I thought it's worthwhile to share it here.
// Class for define Template, this class will added to your app_Code folder.
public class SampleTemplate : ITemplate
{
private string _DataField;
public SampleTemplate (string DataField)
{
this._DataField = DataField;
}
public void InstantiateIn(Control container)
{
TextBox txtItemVal = new TextBox();
txtItemVal.DataBinding += new EventHandler(this.OnDataBinding);
txtItemVal .ID = "txtItemVal";
container.Controls.Add(txtItemVal);
}
public void OnDataBinding(object sender, EventArgs e)
{
TextBox TXT = (TextBox)sender;
GridViewRow container = (GridViewRow)TXT.NamingContainer;
string id = ((DataRowView)container.DataItem)[_DataField].ToString();
TXT.Text= id;
}
}
Adding template to your grid.code behind file.In my case i am going through a for loop with in the user datacolumns datatable and adding coloumns to gridview.
TemplateField tmpItem= new TemplateField();
// you have to specify column name as "datafield" here.as for the gridview data source.lets say you //have Employee datatable.and you want to show Empage in this template coloumn.then you should //use empAge as your dataField
SampleTemplate TEMP1 = new SampleTemplate ("Empage");
tmpUnits.HeaderText = "Employee Age"
tmpUnits.ItemTemplate = TEMP1;
gvTransaction.Columns.Add(tmpItem);
Thats it.Hope this will help you one day.And there's a another way also.will tell you latter. ;)
A GridView template is a class that implements the ITemplate interface. It defines the controls that will be displayed on the GridView in a column.I thought it's worthwhile to share it here.
// Class for define Template, this class will added to your app_Code folder.
public class SampleTemplate : ITemplate
{
private string _DataField;
public SampleTemplate (string DataField)
{
this._DataField = DataField;
}
public void InstantiateIn(Control container)
{
TextBox txtItemVal = new TextBox();
txtItemVal.DataBinding += new EventHandler(this.OnDataBinding);
txtItemVal .ID = "txtItemVal";
container.Controls.Add(txtItemVal);
}
public void OnDataBinding(object sender, EventArgs e)
{
TextBox TXT = (TextBox)sender;
GridViewRow container = (GridViewRow)TXT.NamingContainer;
string id = ((DataRowView)container.DataItem)[_DataField].ToString();
TXT.Text= id;
}
}
Adding template to your grid.code behind file.In my case i am going through a for loop with in the user datacolumns datatable and adding coloumns to gridview.
TemplateField tmpItem= new TemplateField();
// you have to specify column name as "datafield" here.as for the gridview data source.lets say you //have Employee datatable.and you want to show Empage in this template coloumn.then you should //use empAge as your dataField
SampleTemplate TEMP1 = new SampleTemplate ("Empage");
tmpUnits.HeaderText = "Employee Age"
tmpUnits.ItemTemplate = TEMP1;
gvTransaction.Columns.Add(tmpItem);
Thats it.Hope this will help you one day.And there's a another way also.will tell you latter. ;)
Thursday, June 07, 2007
Mahalo
Hi, I found this Mahalo while i am surfing the web.Mahalo is Hawaiian word for Thank You.But thats not the thing which i am going to talk about.Mahalo is the world's first human-powered search engine powered by an enthusiastic and energetic group of Guides.Means .Mahalo Loads only built sreach results by Mahalo Search guides.Mahalo Search guides spend their time to searching ,filtering out spam, and hand-crafting the best search results possible.If they havent built a search result, you have to request that search result. Meaning every search result is carefully reviewed by humans to select the best search results and filtering out spams.
Monday, March 12, 2007
ArrayList vs List<> Generics
when i am working with my new Team in the new place i have got a chance to work with new Generic lists witch has available in .net 2.0. when i am finding information about generic list i understood it's much more better than arraylist. i just checked
Time taken by Collection: 7044.6912 ms
Time taken by Generic: 2898.9216 ms
i just wrote small program using arraylist and the generic list witch is giving the same result.what i understood is on the Generic list you can only assign int (as for the my code.You can supply data type in to List's <> ) to the list - anything else will raise an exception.If you wanted to store a multitude of types, simply inherit from a common base, and use the base as the list identifier.(Use .GetType() ) if i simply says generic list is simple and Safe. :)
if we used arraylist in our code it has to more boxing operations b'coz it can any type.but in generic list is not allowed as i said
here is the code for what i did.
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
namespace Listcompare
{
class Program
{
public static DateTime startTime;
public static DateTime endTime;
public static TimeSpan timeSpan;
private void CheckGenerics()
{
int total = 0;
List lstMyList = new List();
int i = 0;
for (i = 0; i < 20; i++)
lstMyList.Add(i);
for (i = 0; i < 10000000; i++)
foreach (int el in lstMyList)
total += el;
}
private void CheckCollections()
{
int total = 0;
ArrayList al = new ArrayList();
int j = 0;
for (j = 0; j < 20; j++)
al.Add(j);
for (j = 0; j < 10000000; j++)
foreach (int el in al)
total += el;
}
private void Run()
{
startTime = DateTime.Now;
CheckCollections();
endTime = DateTime.Now;
timeSpan = endTime.Subtract(startTime);
Console.Out.WriteLine("Time taken by Collection: " + timeSpan.TotalMilliseconds + " ms");
startTime = DateTime.Now;
CheckGenerics();
endTime = DateTime.Now;
timeSpan = endTime.Subtract(startTime);
Console.Out.WriteLine("Time taken by Generic: " + timeSpan.TotalMilliseconds + " ms");
Console.WriteLine("");
Console.Read();
}
static void Main(string[] args)
{
Program myPgm = new Program();
myPgm.Run();
}
}
}
Time taken by Collection: 7044.6912 ms
Time taken by Generic: 2898.9216 ms
i just wrote small program using arraylist and the generic list witch is giving the same result.what i understood is on the Generic list you can only assign int (as for the my code.You can supply data type in to List's <> ) to the list - anything else will raise an exception.If you wanted to store a multitude of types, simply inherit from a common base, and use the base as the list identifier.(Use .GetType() ) if i simply says generic list is simple and Safe. :)
if we used arraylist in our code it has to more boxing operations b'coz it can any type.but in generic list is not allowed as i said
here is the code for what i did.
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
namespace Listcompare
{
class Program
{
public static DateTime startTime;
public static DateTime endTime;
public static TimeSpan timeSpan;
private void CheckGenerics()
{
int total = 0;
List
int i = 0;
for (i = 0; i < 20; i++)
lstMyList.Add(i);
for (i = 0; i < 10000000; i++)
foreach (int el in lstMyList)
total += el;
}
private void CheckCollections()
{
int total = 0;
ArrayList al = new ArrayList();
int j = 0;
for (j = 0; j < 20; j++)
al.Add(j);
for (j = 0; j < 10000000; j++)
foreach (int el in al)
total += el;
}
private void Run()
{
startTime = DateTime.Now;
CheckCollections();
endTime = DateTime.Now;
timeSpan = endTime.Subtract(startTime);
Console.Out.WriteLine("Time taken by Collection: " + timeSpan.TotalMilliseconds + " ms");
startTime = DateTime.Now;
CheckGenerics();
endTime = DateTime.Now;
timeSpan = endTime.Subtract(startTime);
Console.Out.WriteLine("Time taken by Generic: " + timeSpan.TotalMilliseconds + " ms");
Console.WriteLine("");
Console.Read();
}
static void Main(string[] args)
{
Program myPgm = new Program();
myPgm.Run();
}
}
}
Subscribe to:
Posts (Atom)