最新评论
一品梅 2008-08-21 17:12
--引用--------------------------------------------------
游客: 极力BS发贴不负责、不全的XX
--------------------------------------------------------
晕,没看到我是转载么?何况核心的东西和一个思路告诉你就不错了,难道你连自己发挥的能力都没有吗?那么软件业不成为了极端SB的CTRL+C,CTRL+V行业了.首先解决的是,理解核心思想及所用知识点.
游客: 极力BS发贴不负责、不全的XX
--------------------------------------------------------
晕,没看到我是转载么?何况核心的东西和一个思路告诉你就不错了,难道你连自己发挥的能力都没有吗?那么软件业不成为了极端SB的CTRL+C,CTRL+V行业了.首先解决的是,理解核心思想及所用知识点.
大宋提刑官 2008-07-09 13:33
ObjectDataSourceMethodEventArgs..::.InputParameters Property
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasourcemethodeventargs.inputparameters.aspx
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasourcemethodeventargs.inputparameters.aspx
大宋提刑官 2008-07-09 13:01
ObjectDataSourceStatusEventArgs Class
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasourcestatuseventargs.aspx
-----------------------------------------------
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS" Assembly="Samples.AspNet.CS" %>
<%@ Import namespace="Samples.AspNet.CS" %>
<%@ Page language="c#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
private void NorthwindEmployeeDeleting(object source, ObjectDataSourceMethodEventArgs e)
{
// The GridView passes the ID of the employee
// to be deleted. However, the buisiness object, EmployeeLogic,
// requires a NorthwindEmployee parameter, named "ne". Create
// it now and add it to the parameters collection.
IDictionary paramsFromPage = e.InputParameters;
if (paramsFromPage["EmpID"] != null) {
NorthwindEmployee ne
= new NorthwindEmployee( Int32.Parse(paramsFromPage["EmpID"].ToString()));
// Remove the old EmpID parameter.
paramsFromPage.Clear();
paramsFromPage.Add("ne", ne);
}
}
private void NorthwindEmployeeDeleted(object source, ObjectDataSourceStatusEventArgs e)
{
// Handle the Exception if it is a NorthwindDataException
if (e.Exception != null)
{
// Handle the specific exception type. The ObjectDataSource wraps
// any Exceptions in a TargetInvokationException wrapper, so
// check the InnerException property for expected Exception types.
if (e.Exception.InnerException is NorthwindDataException)
{
Label1.Text = e.Exception.InnerException.Message;
// Because the exception is handled, there is
// no reason to throw it.
e.ExceptionHandled = true;
}
}
}
</script>
<html >
<head>
<title>ObjectDataSource - C# Example</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<asp:gridview
id="GridView1"
runat="server"
datasourceid="ObjectDataSource1"
autogeneratedeletebutton="true"
autogeneratecolumns="false"
datakeynames="EmpID">
<columns>
<asp:boundfield headertext="EmpID" datafield="EmpID" />
<asp:boundfield headertext="First Name" datafield="FirstName" />
<asp:boundfield headertext="Last Name" datafield="LastName" />
</columns>
</asp:gridview>
<asp:objectdatasource
id="ObjectDataSource1"
runat="server"
selectmethod="GetAllEmployees"
deletemethod="DeleteEmployee"
ondeleting="NorthwindEmployeeDeleting"
ondeleted="NorthwindEmployeeDeleted"
typename="Samples.AspNet.CS.EmployeeLogic">
<deleteparameters>
<asp:parameter name="EmpID" type="Int32" />
</deleteparameters>
</asp:objectdatasource>
<asp:label id="Label1" runat="server" />
</form>
</body>
</html>
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasourcestatuseventargs.aspx
-----------------------------------------------
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS" Assembly="Samples.AspNet.CS" %>
<%@ Import namespace="Samples.AspNet.CS" %>
<%@ Page language="c#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
private void NorthwindEmployeeDeleting(object source, ObjectDataSourceMethodEventArgs e)
{
// The GridView passes the ID of the employee
// to be deleted. However, the buisiness object, EmployeeLogic,
// requires a NorthwindEmployee parameter, named "ne". Create
// it now and add it to the parameters collection.
IDictionary paramsFromPage = e.InputParameters;
if (paramsFromPage["EmpID"] != null) {
NorthwindEmployee ne
= new NorthwindEmployee( Int32.Parse(paramsFromPage["EmpID"].ToString()));
// Remove the old EmpID parameter.
paramsFromPage.Clear();
paramsFromPage.Add("ne", ne);
}
}
private void NorthwindEmployeeDeleted(object source, ObjectDataSourceStatusEventArgs e)
{
// Handle the Exception if it is a NorthwindDataException
if (e.Exception != null)
{
// Handle the specific exception type. The ObjectDataSource wraps
// any Exceptions in a TargetInvokationException wrapper, so
// check the InnerException property for expected Exception types.
if (e.Exception.InnerException is NorthwindDataException)
{
Label1.Text = e.Exception.InnerException.Message;
// Because the exception is handled, there is
// no reason to throw it.
e.ExceptionHandled = true;
}
}
}
</script>
<html >
<head>
<title>ObjectDataSource - C# Example</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<asp:gridview
id="GridView1"
runat="server"
datasourceid="ObjectDataSource1"
autogeneratedeletebutton="true"
autogeneratecolumns="false"
datakeynames="EmpID">
<columns>
<asp:boundfield headertext="EmpID" datafield="EmpID" />
<asp:boundfield headertext="First Name" datafield="FirstName" />
<asp:boundfield headertext="Last Name" datafield="LastName" />
</columns>
</asp:gridview>
<asp:objectdatasource
id="ObjectDataSource1"
runat="server"
selectmethod="GetAllEmployees"
deletemethod="DeleteEmployee"
ondeleting="NorthwindEmployeeDeleting"
ondeleted="NorthwindEmployeeDeleted"
typename="Samples.AspNet.CS.EmployeeLogic">
<deleteparameters>
<asp:parameter name="EmpID" type="Int32" />
</deleteparameters>
</asp:objectdatasource>
<asp:label id="Label1" runat="server" />
</form>
</body>
</html>
大宋提刑官 2008-07-08 09:35
Note one thing here: we are not making any explicit call to the constructor of base class neither by initializer nor by the base keyword, but it is still executing. This is the normal behavior of the constructor.
大宋提刑官 2008-07-08 09:34
An Intro to Constructors in C#http://www.codeproject.com/KB/dotnet/ConstructorsInCSharp.aspx
public class myBaseClass
{
public myBaseClass()
{
// Code for First Base class Constructor
}
public myBaseClass(int Age)
{
// Code for Second Base class Constructor
}
// Other class members goes here
}
public class myDerivedClass : myBaseClass
// Note that I am inheriting the class here.
{
public myDerivedClass()
{
// Code for the First myDerivedClass Constructor.
}
public myDerivedClass(int Age):base(Age)
{
// Code for the Second myDerivedClass Constructor.
}
// Other class members goes here
}
Now, what will be the execution sequence here:
If I create the object of the derived class as:
myDerivedClass obj = new myDerivedClass()
Then the sequence of execution will be:
public myBaseClass() method.
and then public myDerivedClass() method.
public class myBaseClass
{
public myBaseClass()
{
// Code for First Base class Constructor
}
public myBaseClass(int Age)
{
// Code for Second Base class Constructor
}
// Other class members goes here
}
public class myDerivedClass : myBaseClass
// Note that I am inheriting the class here.
{
public myDerivedClass()
{
// Code for the First myDerivedClass Constructor.
}
public myDerivedClass(int Age):base(Age)
{
// Code for the Second myDerivedClass Constructor.
}
// Other class members goes here
}
Now, what will be the execution sequence here:
If I create the object of the derived class as:
myDerivedClass obj = new myDerivedClass()
Then the sequence of execution will be:
public myBaseClass() method.
and then public myDerivedClass() method.
大宋提刑官 2008-06-28 10:13
using System;
public interface IComparable
{
int CompareTo(IComparable comp);
}
class Person : IComparable
{
private string name;
private int age;
public Person() : this("", 0) { }
public Person(string name) : this(name, 0) { }
public Person(string name, int age)
{
this.name = name;
this.age = age;
}
public string Name
{
get { return this.name; }
}
public int Age
{
get { return this.age; }
}
#region IComparable 成员
public virtual int CompareTo(IComparable comp)
{
Person temp = (Person)comp;
if (this.age > temp.age)
return 1;
else if (this.age == temp.age)
return 0;
else
return -1;
}
#endregion
}
class BubbleSorter
{
private BubbleSorter() { }
public static void BubbleSortAscending(IComparable[] arr)
{
for (int i = 1; i < arr.Length; i++)
{
for (int j = 0; j < arr.Length - i; j++)
{
if (arr[j].CompareTo(arr[j + 1]) > 0)
{
IComparable temp;
temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
}
class PersonBubbleTest
{
static void Main(string[] args)
{
Person[] p = new Person[4];
p[0] = new Person("aa", 29);
p[1] = new Person("bb", 30);
p[2] = new Person("cc", 21);
p[3] = new Person("dd", 19);
BubbleSorter.BubbleSortAscending(p);
foreach (Person temp in p)
{
Console.WriteLine("Name: {0}, Age: {1}", temp.Name, temp.Age);
}
}
}
public interface IComparable
{
int CompareTo(IComparable comp);
}
class Person : IComparable
{
private string name;
private int age;
public Person() : this("", 0) { }
public Person(string name) : this(name, 0) { }
public Person(string name, int age)
{
this.name = name;
this.age = age;
}
public string Name
{
get { return this.name; }
}
public int Age
{
get { return this.age; }
}
#region IComparable 成员
public virtual int CompareTo(IComparable comp)
{
Person temp = (Person)comp;
if (this.age > temp.age)
return 1;
else if (this.age == temp.age)
return 0;
else
return -1;
}
#endregion
}
class BubbleSorter
{
private BubbleSorter() { }
public static void BubbleSortAscending(IComparable[] arr)
{
for (int i = 1; i < arr.Length; i++)
{
for (int j = 0; j < arr.Length - i; j++)
{
if (arr[j].CompareTo(arr[j + 1]) > 0)
{
IComparable temp;
temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
}
class PersonBubbleTest
{
static void Main(string[] args)
{
Person[] p = new Person[4];
p[0] = new Person("aa", 29);
p[1] = new Person("bb", 30);
p[2] = new Person("cc", 21);
p[3] = new Person("dd", 19);
BubbleSorter.BubbleSortAscending(p);
foreach (Person temp in p)
{
Console.WriteLine("Name: {0}, Age: {1}", temp.Name, temp.Age);
}
}
}
大宋提刑官 2008-06-28 10:13
Sortedlist 本来就是按键排序的键值对集合,不能按楼主所说的Value来排序
如果要实现楼主实现的功能,楼主必须自己写一个实现IComparable接口的类
如果要实现楼主实现的功能,楼主必须自己写一个实现IComparable接口的类
大宋提刑官 2008-06-04 16:48
Parameters
address
Type: System..::.String
The URI of the resource to receive the collection.
data
Type: System.Collections.Specialized..::.NameValueCollection
The NameValueCollection to send to the resource.
Return Value
Type: array< System..::.Byte >[]()[]
A Byte array containing the body of the response from the resource
address
Type: System..::.String
The URI of the resource to receive the collection.
data
Type: System.Collections.Specialized..::.NameValueCollection
The NameValueCollection to send to the resource.
Return Value
Type: array< System..::.Byte >[]()[]
A Byte array containing the body of the response from the resource

