如何在网格视图中添加按钮控件,其中在asp.net中自动生成列 [英] How to add button control in grid view where columns generated automatic in asp.net

查看:85
本文介绍了如何在网格视图中添加按钮控件,其中在asp.net中自动生成列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨......

我想在网格视图中添加按钮控件,其中在asp.net中自动生成列.我正在尝试创建允许数据排序和过滤的网格用户控件,其中我将数据集绑定到自动生成列的网格中.我想添加小2标题中的按钮或图像用于向上和向下箭头进行排序.但是我无法这样做.为此提供解决方案以生成具有按asc和desc排序按钮的动态网格.thanx

hi......

How to add button control in grid view where columns generated automatic in asp.net.I am trying to create grid user control allow data sorting and filtering, in which i am binding dataset to grid where columns are autogenerated.I want to add small 2 buttons or images in header for up and down arrow for sorting.but i am not able to do.provide solution for this to generate dynamic grid with buttons to asc and desc sorting.thanx

推荐答案

可以说,您需要在gridView中对第二,第三和第四列进行排序...填充gridview之后,请执行以下操作.

Lets say, you need to sort 2nd 3rd and 4th column in your gridView... After you populate gridview do the following.

gridview.Columns.Clear();
gridview.DataSource = somedatasource;
gridview.AutoGenerateColumns = true;
if (this.gridview.Rows.Count > 0)
{
gridview.Columns[1].SortMode = gridview.Columns[2].SortMode =   gridview.Columns[3].SortMode = DataGridViewColumnSortMode.Automatic;
gridview.Sort(gridview.Columns[1], ListSortDirection.Ascending); //This will put a sort indicator on 2nd column on gridview, and obviously sorted too..
}


这篇关于如何在网格视图中添加按钮控件,其中在asp.net中自动生成列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆