asp.net2.0 GridView Url传递中文参数解决方案

 

  < asp:GridView ID = " GridView1 "  PageSize = " 30 "  runat = " server "  Height = " 100% "  Width = " 100% "  AutoGenerateColumns = " False "  AllowPaging = " True "  EmptyDataText = " 没有数据记录!! "  DataKeyNames = " iProductBigSort_ID "  BackColor = " #EEEEE6 "  OnRowEditing = " GridView1_RowEditing "  onRowCancelingEdit = " GridView1_RowCancelingEdit "  onRowDeleting = " GridView1_RowDeleting "  onRowUpdating = " GridView1_RowUpdating "   >
            
< Columns >  
                
< asp:TemplateField HeaderText = " 主分类名 " >
                    
< ItemTemplate ><% # Eval( " sProductBigSort " ) %></ ItemTemplate >
                    
< EditItemTemplate >< asp:TextBox ID = " sProductBigSort "  Width = " 60% "  runat = " server "  Text =   <% # Eval( " sProductBigSort " ) %>   /></ EditItemTemplate >
                
</ asp:TemplateField >
                
< asp:TemplateField HeaderText = " 管理子分类 " >
                    
< ItemTemplate >
                    
< a href = " Admin_SmallSort.aspx?iProductBigSort_ID=<%# Eval( " iProductBigSort_ID " )%>&sProductBigSort=<%# Server.UrlEncode(Eval( " sProductBigSort " ).ToString())%> " > 查看分类 </ a >
                     
</ ItemTemplate >
                
</ asp:TemplateField >
                
< asp:CommandField ShowEditButton = " True "  HeaderText = " 操作 "  ButtonType = " Button " />                 
                 
< asp:TemplateField HeaderText = " 删除分类 "  ShowHeader = " False " >
                    
< ItemTemplate >
                        
< asp:LinkButton ID = " LinkButton1 "  runat = " server "  CausesValidation = " False "  CommandName = " Delete "  Text = " 删除 "  OnClientClick = " return confirm('严重警告!!此操作非常危险!!\n此操作将会删除以下信息:\n此主分类下的二级、三级小分类、相关品牌以及删除相关的全部产品资料。\n确认要删除吗?'); " ></ asp:LinkButton >
                    
</ ItemTemplate >
                
</ asp:TemplateField >
             
</ Columns >
            
< PagerSettings Visible = " False "   />
        
</ asp:GridView >


// 这就实现了GridView的模板列传递URL参数时进行了编码
/*
a href="Admin_SmallSort.aspx?iProductBigSort_ID=<%# Eval("iProductBigSort_ID")%>&sProductBigSort=<%# Server.UrlEncode(Eval("sProductBigSort").ToString())%>">查看分类</a>
*/



你可能感兴趣的:(GridView)