03 Jul 2006

code-beside方式绑定GridView后EnableSortingAndPagingCallbacks不工作

今天对GridView的学习中发现 当用 code-beside方式绑定GridView后(比如我绑一个DataTable)
EnableSortingAndPagingCallbacks不起作用。
在下面地址找到 一些说法

http://forums.asp.net/thread/1230450.aspx

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=103040
记之…

 1    <asp:GridView id=“Gridviewex1” 
 2    runat=“server” 
 3    AllowSorting=“True” 
 4    AutoGenerateColumns=“False”
 5    EnableSortingAndPagingCallbacks=“True” 
 6    OnSorting=“Gridviewex1_Sorting”>
 7        <Columns>
 8            <asp:BoundField DataField=“ProductId” HeaderText=“ProductId” SortExpression=“ProductId” />
 9            <asp:BoundField DataField=“ProductName” HeaderText=“ProductName” SortExpression=“ProductName” />
10            <asp:BoundField DataField=“QuantityPerUnit” HeaderText=“QuantityPerUnit” SortExpression=“QuantityPerUnit” />
11            <asp:BoundField DataField=“UnitsInStock” HeaderText=“UnitsInStock” SortExpression=“UnitsInStock” />
12            <asp:BoundField DataField=“ReorderLevel” HeaderText=“ReorderLevel” SortExpression=“ReorderLevel” />
13            <asp:BoundField DataField=“Discontinued” HeaderText=“Discontinued” SortExpression=“Discontinued” />
14        </Columns>
15    </aspx:GridView>
 1    protected void Page_Load(object sender, EventArgs e)
 2    {
 3
 4        if (!Page.IsPostBack)
 5        {
 6            this.BindGrid(string.Empty);
 7        }

 8    }

 9
10    private void BindGrid(string sortExpression)
11    {
12        DataTable dt = new DataTable();
13        SqlConnection conn = new SqlConnection();
14        conn.ConnectionString = server=wumeibo\wmb;database=northwind;uid=sa;pwd=sa;;
15        SqlCommand cmd = new SqlCommand();
16        cmd.Connection = conn;
17        cmd.CommandType = CommandType.Text;
18        cmd.CommandText = select * from products;
19        SqlDataAdapter adapter = new SqlDataAdapter();
20        adapter.SelectCommand = cmd;
21        adapter.Fill(dt);
22        DataView dv = dt.DefaultView;;
23        if (!string.IsNullOrEmpty(sortExpression))        
24        {
25            dv = dt.DefaultView;
26            dv.Sort = sortExpression;
27        }

28        this.Gridviewex1.DataSource = dv;
29        this.Gridviewex1.DataBind();
30        
31    }

32    protected void Gridviewex1_Sorting(object sender, GridViewSortEventArgs e)
33    {
34        BindGrid(e.SortExpression);
35    }

经过测试 如下方法 可用

 1     protected void Page_Load(object sender, EventArgs e)
 2     {
 3             xx();
 4         
 5     }
 6 
 7     private void xx()
 8     {
 9         SqlConnection conn = new SqlConnection();
10         conn.ConnectionString = server=wumeibo\wmb;database=northwind;uid=sa;pwd=sa;;
11    
12         SqlDataSource source = new SqlDataSource();
13         source.ConnectionString = server=wumeibo\wmb;database=northwind;uid=sa;pwd=sa;;
14         source.SelectCommand = select * from products;
15 
16         this.Gridviewex1.DataSource = source;
17         this.Gridviewex1.DataBind();
18     }

03 Jul 2006

code-beside方式绑定GridView后EnableSortingAndPagingCallbacks不工作

今天对GridView的学习中发现 当用 code-beside方式绑定GridView后(比如我绑一个DataTable)
EnableSortingAndPagingCallbacks不起作用。
在下面地址找到 一些说法

http://forums.asp.net/thread/1230450.aspx

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=103040
记之…

 1    <asp:GridView id=“Gridviewex1” 
 2    runat=“server” 
 3    AllowSorting=“True” 
 4    AutoGenerateColumns=“False”
 5    EnableSortingAndPagingCallbacks=“True” 
 6    OnSorting=“Gridviewex1_Sorting”>
 7        <Columns>
 8            <asp:BoundField DataField=“ProductId” HeaderText=“ProductId” SortExpression=“ProductId” />
 9            <asp:BoundField DataField=“ProductName” HeaderText=“ProductName” SortExpression=“ProductName” />
10            <asp:BoundField DataField=“QuantityPerUnit” HeaderText=“QuantityPerUnit” SortExpression=“QuantityPerUnit” />
11            <asp:BoundField DataField=“UnitsInStock” HeaderText=“UnitsInStock” SortExpression=“UnitsInStock” />
12            <asp:BoundField DataField=“ReorderLevel” HeaderText=“ReorderLevel” SortExpression=“ReorderLevel” />
13            <asp:BoundField DataField=“Discontinued” HeaderText=“Discontinued” SortExpression=“Discontinued” />
14        </Columns>
15    </aspx:GridView>
 1    protected void Page_Load(object sender, EventArgs e)
 2    {
 3
 4        if (!Page.IsPostBack)
 5        {
 6            this.BindGrid(string.Empty);
 7        }

 8    }

 9
10    private void BindGrid(string sortExpression)
11    {
12        DataTable dt = new DataTable();
13        SqlConnection conn = new SqlConnection();
14        conn.ConnectionString = server=wumeibo\wmb;database=northwind;uid=sa;pwd=sa;;
15        SqlCommand cmd = new SqlCommand();
16        cmd.Connection = conn;
17        cmd.CommandType = CommandType.Text;
18        cmd.CommandText = select * from products;
19        SqlDataAdapter adapter = new SqlDataAdapter();
20        adapter.SelectCommand = cmd;
21        adapter.Fill(dt);
22        DataView dv = dt.DefaultView;;
23        if (!string.IsNullOrEmpty(sortExpression))        
24        {
25            dv = dt.DefaultView;
26            dv.Sort = sortExpression;
27        }

28        this.Gridviewex1.DataSource = dv;
29        this.Gridviewex1.DataBind();
30        
31    }

32    protected void Gridviewex1_Sorting(object sender, GridViewSortEventArgs e)
33    {
34        BindGrid(e.SortExpression);
35    }

经过测试 如下方法 可用

 1     protected void Page_Load(object sender, EventArgs e)
 2     {
 3             xx();
 4         
 5     }
 6 
 7     private void xx()
 8     {
 9         SqlConnection conn = new SqlConnection();
10         conn.ConnectionString = server=wumeibo\wmb;database=northwind;uid=sa;pwd=sa;;
11    
12         SqlDataSource source = new SqlDataSource();
13         source.ConnectionString = server=wumeibo\wmb;database=northwind;uid=sa;pwd=sa;;
14         source.SelectCommand = select * from products;
15 
16         this.Gridviewex1.DataSource = source;
17         this.Gridviewex1.DataBind();
18     }

29 Jun 2006

还记得 Page.SmartNavigation 属性么,此属性已被否决。

还记得在.Net 1.x 中我们为了保持在页面回发后 保持滚动条位置的做法么?
Page.SmartNavigation 可以做到,但会带来这样那样的问题。
我们也曾经用这样那样的方法实现这个效果,如:

http://huobazi.cnblogs.com/archive/2004/09/20/ScrollPage.aspx
http://www.cnblogs.com/birdshome/archive/2004/12/13/76521.html

在.Net 2.0 中,该类型被描述为:
 
[ObsoleteAttribute("The recommended alternative is Page.SetFocus and Page.MaintainScrollPositionOnPostBack. http://go.microsoft.com/fwlink/?linkid=14202")]
public bool SmartNavigation { get; set; }


注意:此属性现在已过时。

 

获取或设置指示是否启用智能导航的值。

同时在备注内有提到:

SmartNavigation 属性已被否决。请改用 SetFocus 方法和 MaintainScrollPositionOnPostback 属性。

园子里birdshome 也早有post了 SmartNavigation在Fx2.0中下岗了

29 Jun 2006

还记得 Page.SmartNavigation 属性么,此属性已被否决。

还记得在.Net 1.x 中我们为了保持在页面回发后 保持滚动条位置的做法么?
Page.SmartNavigation 可以做到,但会带来这样那样的问题。
我们也曾经用这样那样的方法实现这个效果,如:

http://huobazi.cnblogs.com/archive/2004/09/20/ScrollPage.aspx
http://www.cnblogs.com/birdshome/archive/2004/12/13/76521.html

在.Net 2.0 中,该类型被描述为:
 
[ObsoleteAttribute("The recommended alternative is Page.SetFocus and Page.MaintainScrollPositionOnPostBack. http://go.microsoft.com/fwlink/?linkid=14202")]
public bool SmartNavigation { get; set; }


注意:此属性现在已过时。

 

获取或设置指示是否启用智能导航的值。

同时在备注内有提到:

SmartNavigation 属性已被否决。请改用 SetFocus 方法和 MaintainScrollPositionOnPostback 属性。

园子里birdshome 也早有post了 SmartNavigation在Fx2.0中下岗了

25 May 2006

比尔盖茨的又一个网站

 


http://www.iis.net/default.aspx?tabid=1

18 May 2006

在Asp.Net2.0中可以方便的访问配置文件web.config,如判断debug设置,验证类型等。

Asp.Net2.0中我们可以方便的访问配置文件中,.NetFrameWork2.0新增加了 SystemWebSectionGroup 类。
允许用户以编程方式访问配置文件的 system.web 组。
比如判断web.config内是否为 debug=“true”,或者判断身份验证形式

    SystemWebSectionGroup ws = new SystemWebSectionGroup();
    CompilationSection cp = ws.Compilation;
    用cp.Debug;就可以得到compilation节内关于”debug”的配置
     AuthenticationSection  as = ws.Authentication; 
    用 as.Mode  可以获取 authentication节中关于”mode”的配置,值为AuthenticationMode 枚举之一
AuthenticationMode的取值如下:

  成员名称 说明
  Forms 将基于 ASP.NET 窗体的身份验证指定为身份验证模式。 
  None 不指定身份验证。 
  Passport 将 Microsoft Passport 指定为身份验证模式。 
  Windows 将 Windows 指定为身份验证模式。在使用 Internet 信息服务 (IIS) 身份验证方法(基本、简要、集成 Windows (NTLM/Kerberos) 或证书)时适用此模式。 

    
附:SystemWebSectionGroup 类的公共属性:

  名称 说明
Public property AnonymousIdentification 获取 anonymousIdentification 节。
Public property Authentication 获取 authentication 节。
Public property Authorization 获取 authorization 节。
Public property BrowserCaps 获取 browserCaps 节。
Public property ClientTarget 获取 clientTarget 节。
Public property Compilation 获取 compilation 节。
Public property CustomErrors 获取 customErrors 节。
Public property Deployment 获取 deployment 节。
Public property DeviceFilters 获取 deviceFilters 节。
Public property Globalization 获取 globalization 节。
Public property HealthMonitoring 获取 healthMonitoring 节。
Public property HostingEnvironment 获取 hostingEnvironment 节。
Public property HttpCookies 获取 httpCookies 节。
Public property HttpHandlers 获取 httpHandlers 节。
Public property HttpModules 获取 httpModules 节。
Public property HttpRuntime 获取 httpRuntime 节。
Public property Identity 获取 identity 节。
Public property IsDeclarationRequired  获取一个值,该值指示是否需要声明此 ConfigurationSectionGroup 对象。 (从 ConfigurationSectionGroup 继承。)
Public property IsDeclared  获取一个值,该值指示是否已声明此 ConfigurationSectionGroup 对象。(从 ConfigurationSectionGroup 继承。)
Public property MachineKey 获取 machineKey 节。
Public property Membership 获取 membership 节。
Public property MobileControls 获取 mobileControls 节。
Public property Name  获取此 ConfigurationSectionGroup 对象的名称属性。(从 ConfigurationSectionGroup 继承。)
Public property Pages 获取 pages 节。
Public property ProcessModel 获取 processModel 节。
Public property Profile 获取 profile 节。
Public property Protocols 获取 protocols 节。
Public property RoleManager 获取 roleManager 节。
Public property SectionGroupName  获取与此 ConfigurationSectionGroup 关联的节组名称。(从 ConfigurationSectionGroup 继承。)
Public property SectionGroups  获取一个包含所有 ConfigurationSectionGroup 对象的 ConfigurationSectionGroup 对象,这些对象是此 ConfigurationSectionGroup 对象的子对象。(从 ConfigurationSectionGroup 继承。)
Public property Sections  获取一个 ConfigurationSectionCollection,它包含此 ConfigurationSectionGroup 中的所有 ConfigurationSection 对象。(从 ConfigurationSectionGroup 继承。)
Public property SecurityPolicy 获取 securityPolicy 节。
Public property SessionState 获取 sessionState 节。
Public property SiteMap 获取 siteMap 节。
Public property Trace 获取 trace 节。
Public property Trust 获取 trust 节。
Public property Type  获取或设置此 ConfigurationSectionGroup 对象的类型。(从 ConfigurationSectionGroup 继承。)
Public property UrlMappings 获取 urlMappings 节。
Public property WebControls 获取 webControls 节。
Public property WebParts 获取 webParts 节。
Public property WebServices 获取 webServices 节。
Public property XhtmlConformance 获取 xhtmlConformance 节。

18 May 2006

在Asp.Net2.0中可以方便的访问配置文件web.config,如判断debug设置,验证类型等。

Asp.Net2.0中我们可以方便的访问配置文件中,.NetFrameWork2.0新增加了 SystemWebSectionGroup 类。
允许用户以编程方式访问配置文件的 system.web 组。
比如判断web.config内是否为 debug=“true”,或者判断身份验证形式

    SystemWebSectionGroup ws = new SystemWebSectionGroup();
    CompilationSection cp = ws.Compilation;
    用cp.Debug;就可以得到compilation节内关于”debug”的配置
     AuthenticationSection  as = ws.Authentication; 
    用 as.Mode  可以获取 authentication节中关于”mode”的配置,值为AuthenticationMode 枚举之一
AuthenticationMode的取值如下:

  成员名称 说明
  Forms 将基于 ASP.NET 窗体的身份验证指定为身份验证模式。 
  None 不指定身份验证。 
  Passport 将 Microsoft Passport 指定为身份验证模式。 
  Windows 将 Windows 指定为身份验证模式。在使用 Internet 信息服务 (IIS) 身份验证方法(基本、简要、集成 Windows (NTLM/Kerberos) 或证书)时适用此模式。 

    
附:SystemWebSectionGroup 类的公共属性:

  名称 说明
Public property AnonymousIdentification 获取 anonymousIdentification 节。
Public property Authentication 获取 authentication 节。
Public property Authorization 获取 authorization 节。
Public property BrowserCaps 获取 browserCaps 节。
Public property ClientTarget 获取 clientTarget 节。
Public property Compilation 获取 compilation 节。
Public property CustomErrors 获取 customErrors 节。
Public property Deployment 获取 deployment 节。
Public property DeviceFilters 获取 deviceFilters 节。
Public property Globalization 获取 globalization 节。
Public property HealthMonitoring 获取 healthMonitoring 节。
Public property HostingEnvironment 获取 hostingEnvironment 节。
Public property HttpCookies 获取 httpCookies 节。
Public property HttpHandlers 获取 httpHandlers 节。
Public property HttpModules 获取 httpModules 节。
Public property HttpRuntime 获取 httpRuntime 节。
Public property Identity 获取 identity 节。
Public property IsDeclarationRequired  获取一个值,该值指示是否需要声明此 ConfigurationSectionGroup 对象。 (从 ConfigurationSectionGroup 继承。)
Public property IsDeclared  获取一个值,该值指示是否已声明此 ConfigurationSectionGroup 对象。(从 ConfigurationSectionGroup 继承。)
Public property MachineKey 获取 machineKey 节。
Public property Membership 获取 membership 节。
Public property MobileControls 获取 mobileControls 节。
Public property Name  获取此 ConfigurationSectionGroup 对象的名称属性。(从 ConfigurationSectionGroup 继承。)
Public property Pages 获取 pages 节。
Public property ProcessModel 获取 processModel 节。
Public property Profile 获取 profile 节。
Public property Protocols 获取 protocols 节。
Public property RoleManager 获取 roleManager 节。
Public property SectionGroupName  获取与此 ConfigurationSectionGroup 关联的节组名称。(从 ConfigurationSectionGroup 继承。)
Public property SectionGroups  获取一个包含所有 ConfigurationSectionGroup 对象的 ConfigurationSectionGroup 对象,这些对象是此 ConfigurationSectionGroup 对象的子对象。(从 ConfigurationSectionGroup 继承。)
Public property Sections  获取一个 ConfigurationSectionCollection,它包含此 ConfigurationSectionGroup 中的所有 ConfigurationSection 对象。(从 ConfigurationSectionGroup 继承。)
Public property SecurityPolicy 获取 securityPolicy 节。
Public property SessionState 获取 sessionState 节。
Public property SiteMap 获取 siteMap 节。
Public property Trace 获取 trace 节。
Public property Trust 获取 trust 节。
Public property Type  获取或设置此 ConfigurationSectionGroup 对象的类型。(从 ConfigurationSectionGroup 继承。)
Public property UrlMappings 获取 urlMappings 节。
Public property WebControls 获取 webControls 节。
Public property WebParts 获取 webParts 节。
Public property WebServices 获取 webServices 节。
Public property XhtmlConformance 获取 xhtmlConformance 节。

10 May 2006

推荐一个.Net做的图形处理软件--Paint.NET

 

Home   Features     Download   Roadmap   Screenshots   Forum  

AboutPaint.NET is image and photo manipulation software designed to be used on computers that run Windows 2000, XP, Vista, or Server 2003. It supports layers, unlimited undo, special effects, and a wide variety of useful and powerful tools.

The programming language used to create Paint.NET is C#, with a small amount of C++ for setup and shell-integration related functionality


10 May 2006

推荐一个.Net做的图形处理软件--Paint.NET

 

Home   Features     Download   Roadmap   Screenshots   Forum  

AboutPaint.NET is image and photo manipulation software designed to be used on computers that run Windows 2000, XP, Vista, or Server 2003. It supports layers, unlimited undo, special effects, and a wide variety of useful and powerful tools.

The programming language used to create Paint.NET is C#, with a small amount of C++ for setup and shell-integration related functionality


04 May 2006

Vs2005的倒退?

String abc = 123.ToString;

代码在Vs2003内编译将得到错误信息

在不带括号的情况下引用了方法.....

在Vs2005(8.050727.42 /rtm 50727 4200)内编译则得到错误信息:

“无法将方法组“ToString”转换为非委托类型“string”。您是要调用方法吗?”

而上边代码等号右边的部分如果位于一个方法内做参数,那将得到一个错误信息:

参数“1”: 无法从“方法组”转换为“string”

语气上更加亲切了,比如多了个“您”字,可是语意上却更加看不懂了....