gridview

清空gridview

吃可爱长大的小学妹 提交于 2020-03-13 05:39:20
想清空gridview里面的内容,于是把绑定的datatable清空设成了null。可是测试gridview无法清空,里面还是显示之前的内容。 原来当要绑定的datatable为null的时候,即使指定要gridview绑定,也是绑不上地~ 这时候只要重新建个新的datatable绑定就好了 protected void rgData_NeedDataSource( object source, Telerik.WebControls.GridNeedDataSourceEventArgs e) { DataTable dt = (DataTable)ViewState[ " dtemp " ]; this .rgData.DataSource = dt== null ? new DataTable():dt; } 来源: https://www.cnblogs.com/neru/archive/2012/03/07/2383605.html

对gridView数据进行筛选 GetDataTable_LikeString

喜夏-厌秋 提交于 2020-03-12 13:40:34
/// <summary> /// 对gridView数据进行筛选 返回RowFilter 字符,如果有PY列,则会一并处理 注意 返回是 and (xxx like xxx) 有And 进行连接 /// </summary> /// <param name="view">要筛选的GridView 仅处理显示列</param> /// <param name="_inputTxt">要筛选的文本,中间可以有空格,具体空格用途见第三个参数,注意不要对用户录入的txt做特殊字符过滤处理</param> /// <param name="comperType">如果要筛选的文本,中间可以有空格,则要如何处理,默认不处理 类似如 用户录入 湖南 长沙,可以筛选出包含湖南和长沙的内容 </param> /// <returns>注意 返回是 and (xxx like xxx) 有And 进行连接</returns> public static string GetDataTable_LikeString(DevExpress.XtraGrid.Views.Grid.GridView view, string _inputTxt, EnComperType comperType = EnComperType.None) { if (view == null || view

自己写的Gridview分页功能

大憨熊 提交于 2020-03-11 18:34:56
先写个Pages.cs类 最好放在 App_Code里 Code 1 using System; 2 using System.Data; 3 using System.Configuration; 4 using System.Web; 5 using System.Web.Security; 6 using System.Web.UI; 7 using System.Web.UI.WebControls; 8 using System.Web.UI.WebControls.WebParts; 9 using System.Web.UI.HtmlControls; 10 11 12 /**/ /// <summary> 13 /// Page 的摘要说明 14 /// </summary> 15 public class Pages 16 { 17 // 获得每页记录数 18 19 static int pageSize = 8 ; // 每页记录数 20 public Pages() 21 { 22 // TODO: 在此处添加构造函数逻辑 23 } 24 25 /**/ /* ********************************************************************************************** 26 *

GRIDVIEW 用法

♀尐吖头ヾ 提交于 2020-03-10 23:43:36
一、GridView和DataGrid的异同 GridView 是 DataGrid的后继控件,在.net framework 2 中,虽然还存在DataGrid,但是GridView已经走上了历史的前台,取代DataGrid的趋势已是势不可挡。GridView和DataGrid功能相似,都是在web页面中显示数据源中的数据,将数据源中的一行数据,也就是一条记录,显示为在web页面上输出表格中的一行。 GridView相对于DataGrid来说,具有如下优势,功能上更加丰富,因为提供了智能标记面板(也就是show smart tag)更加易用方便,常用的排序、分页、更新、删除等操作可以零代码实现!具有PagerTemplate属性,可以自定义用户导航页面,也就是说分页的控制更加随心所欲。GridView和DataGrid在事件模型上也多有不同之处,DataGrid控件引发的都是单个事件,而GridView控件会引发两个事件,一个在操作前发生,一个在操作后发生,操作前的事件多位***ing事件,操作后的事件多位***ed事件,比如Sorting 事件和sorted 事件,RowDeleting和RowDeleted事件。 二、GridView操作初步 1、显示数据源中的数据 从ToolBox中选取GridView控件拖到页面上,然后点击右键,选择Show Smart Tag

XtraGrid gridview基本用法

无人久伴 提交于 2020-03-10 23:03:46
DevExpress XtraGrid的功能实在强大,刚使用的时候看到一大片属性设置,分不清东南西北,参照demo和使用中的一些经验,记录一下使用方法。现在数据库访问都使用ORM技术了,对于DataSouce绑定以下是以IList为说明对象。 控件基本定义 DevExpress.XtraGrid.GridControl gridControl1; 1、 数据绑定(IList) DevExpress.XtraGrid.Views.Grid.GridView gridView1; IList<MyClass> list = new BindingList<MyClass>(); //初始list list.Add(A); list.Add(B); ……….. gridControl1.DataSource = list; 2、 在Grid上编辑数据 修改属性gridView1.OptionsView.NewItemRowPosition,设为Top或Bottom可以在Grid上添加数据。 (在demo中原文:a record object must be inherited from the IEditableObject class if you need the ability to cancel newly added records via the grid) 译

GridView导出excel格式问题

人走茶凉 提交于 2020-03-10 03:52:25
在导出的点击事件中,代码如下: //指定导出对应单元格为文本样式 string style = @"<style> .test { vnd.ms-excel.numberformat:@; } </style> "; Response.ClearContent(); Response.AddHeader("content-disposition", "attachment; filename=MyExcelFile.xls"); Response.ContentType = "application/excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); gvwCheckExcepton.RenderControl(htw); Response.Write(style);//输出样式 Response.Write(sw.ToString());//输出内容 Response.End(); 在 gridview事件为RowDataBound指定哪些列需要指定格式 protected void gvwCheckExcepton_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row

共享GridView DataGrid DataTable导出到Excel代码

萝らか妹 提交于 2020-03-10 03:46:05
下面是一个导出Excel文件的代码。 code using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; namespace Test { /**/ /// <summary> /// 重载样例 /// </summary> public class GridViewExport : ExcelExport { public GridViewExport(DataTable dt) : base (dt, true ) { } public override void GridViewBoundEvent( object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { // e.Row.Cells[1]

通过GridView导出Excel

会有一股神秘感。 提交于 2020-03-10 03:28:35
protected void ToExcel(GridView gv,string name) { Response.Clear(); Response.Buffer = true; Response.Charset = "GB2312"; Response.AppendHeader("Content-Disposition", "attachment;filename=" + name + ".xls"); // 如果设置为 GetEncoding("GB2312");导出的文件将会出现乱码!!! Response.ContentEncoding = System.Text.Encoding.UTF7; Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。 System.IO.StringWriter oStringWriter = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); gv.RenderControl(oHtmlTextWriter); Response.Output.Write

自定义GridView分页模板

青春壹個敷衍的年華 提交于 2020-03-07 08:56:49
GridView较之DataGrid提供了更加强大、更加完善的功能,而且具备了丰富的可扩展功能,可以使用GridView提供的pagertemplate自定义分页模板: 事实上,GridView默认的几中分页样式,都是将相关按钮的CommandName设为Page,而CommandArgument设为相关参数,可接受的参数包括,first,last,prev,next,<PageIndex>(具体数字),然后按事件回溯,触发顶层的RowCommand,因此我们页可以使用这些默认的可识别的参数自定义自己的分页模板,asp.net会自动设置当前的NewPageIndex,而不需要任何的冗余代码。 .aspx页面: <asp:gridview id="GridView1" runat="server" allowpaging="True" pagesize="10" autogeneratecolumns="False" datasourceid="SqlDataSource1" onpageindexchanging="GridView1_PageIndexChanging"> <columns> <asp:boundfield datafield="CompanyName" headertext="CompanyName" sortexpression="CompanyName" /

How to automatically search with out clicking Button

帅比萌擦擦* 提交于 2020-03-06 08:21:59
问题 i have few text boxes and dropdown boxes in a search window,and when click search button it will display data on gridview based on value selection in controls.Now what i want is even without clicking on search button it will display data automatically in gridview based on control selection.How to achieve it.I am posting small snippet contains only text box. UI <div> <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox> </div> <div> <asp:Button ID="Button1" runat="server" Text="Search"