gridview

Get DataKey values in GridView RowCommand

不想你离开。 提交于 2019-12-17 08:29:12
问题 I have a GridView with an associated DataKey , which is the item ID. How do I retrieve that value inside the RowCommand event? This seems to work, but I don't like the cast to LinkButton (what if some other command is firing the event?), and I'm not too confident about the NamingContainer bit. LinkButton lb = (LinkButton)e.CommandSource; GridViewRow gvr = (GridViewRow)lb.NamingContainer; int id = (int)grid.DataKeys[gvr.RowIndex].Value; I'm aware that I could instead pass that ID as the

Paging & Sorting grids with ASP.Net MVC

僤鯓⒐⒋嵵緔 提交于 2019-12-17 07:03:09
问题 Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. I'm new to MVC, and am not following how you'd do paging and sorting on a grid. I'm used to using the asp.Net GridView control with an ObjectDataSource pointed at objects in our business layer - and in that case the ODS handles all of the paging & sorting using the methods that our ORM generates on

Paging & Sorting grids with ASP.Net MVC

那年仲夏 提交于 2019-12-17 07:03:00
问题 Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. I'm new to MVC, and am not following how you'd do paging and sorting on a grid. I'm used to using the asp.Net GridView control with an ObjectDataSource pointed at objects in our business layer - and in that case the ODS handles all of the paging & sorting using the methods that our ORM generates on

WPF : Extend last column of ListView's GridView

倖福魔咒の 提交于 2019-12-17 05:51:57
问题 I have a ListView with a GridView with 3 columns. I want last column to take up remaining width of the ListView. 回答1: That can't be done with simple XAML, but there are some solutions out there. Check this out: ListView Layout Manager Star size of a ListView column 回答2: quick & dirty xaml: <ListView SizeChanged="ListView_SizeChanged" Loaded="ListView_Loaded" > <ListView.View> <GridView> <GridViewColumn Header="col1" Width="100" /> <GridViewColumn Header="col1" Width="Auto" /> <GridViewColumn

WPF : Extend last column of ListView's GridView

主宰稳场 提交于 2019-12-17 05:51:04
问题 I have a ListView with a GridView with 3 columns. I want last column to take up remaining width of the ListView. 回答1: That can't be done with simple XAML, but there are some solutions out there. Check this out: ListView Layout Manager Star size of a ListView column 回答2: quick & dirty xaml: <ListView SizeChanged="ListView_SizeChanged" Loaded="ListView_Loaded" > <ListView.View> <GridView> <GridViewColumn Header="col1" Width="100" /> <GridViewColumn Header="col1" Width="Auto" /> <GridViewColumn

GridView编辑删除操作

雨燕双飞 提交于 2019-12-17 05:15:36
第一种:使用DataSource数据源中自带的编辑删除方法,这样的不经常使用,在这里就不加说明了。 另外一种:使用GridView的三种事件:GridView1_RowEditing(编辑)、GridView1_RowUpdating(更新)、GridView1_RowCancelingEdit(取消编辑)。 GridView1属性 中将DataKeyNames的值设置为主键名,否则找不到索引,这个非常重要哦。 该方法有2种操作,一种是不正确绑定列转换为模板列,第二种是转换为模板列。 这里先说不转换为模板列的情况; 首先;先对GridView进行数据绑定,无论用代码绑定还是DataSource绑定都能够。绑定好后,对GridView加入绑定列 和编辑列 (注意这里,加入好后不做不论什么修改, 千万不要将它们转换为模板列 ),加入好后,将所要绑定的数据库表字段填入 属性中。 然后,分别激活上述提到的三种事件,然后加入代码: protected void GridView1_RowDeleting (object sender, GridViewDeleteEventArgs e) { //运行删除 string str = "delete from tb_hby where id='"+GridView1.DataKeys[e.RowIndex].Value.ToString()+"

How to hide a column (GridView) but still access its value?

╄→гoц情女王★ 提交于 2019-12-17 05:02:20
问题 I have a GridView with a DataSource (SQL Database). I want to hide a column, but still be able to access the value when I select the record. Can someone show me how to do this? This is the column I want to hide and still want to access its value: <asp:BoundField DataField="Outlook_ID" HeaderText="OutlookID" /> I tried everything to hide the column (property Visible="false" ), but I can't access its value. 回答1: If I am not mistaken, GridView does not hold the values of BoundColumns that have

GridView编辑删除操作

余生颓废 提交于 2019-12-17 03:00:51
第一种:使用DataSource数据源中自带的编辑删除方法,这样的不经常使用,在这里就不加说明了。 另外一种:使用GridView的三种事件:GridView1_RowEditing(编辑)、GridView1_RowUpdating(更新)、GridView1_RowCancelingEdit(取消编辑)。 GridView1属性 中将DataKeyNames的值设置为主键名,否则找不到索引,这个非常重要哦。 该方法有2种操作,一种是不正确绑定列转换为模板列,第二种是转换为模板列。 这里先说不转换为模板列的情况; 首先;先对GridView进行数据绑定,无论用代码绑定还是DataSource绑定都能够。绑定好后,对GridView加入绑定列 和编辑列 (注意这里,加入好后不做不论什么修改, 千万不要将它们转换为模板列 ),加入好后,将所要绑定的数据库表字段填入 属性中。 然后,分别激活上述提到的三种事件,然后加入代码: protected void GridView1_RowDeleting (object sender, GridViewDeleteEventArgs e) { //运行删除 string str = "delete from tb_hby where id='"+GridView1.DataKeys[e.RowIndex].Value.ToString()+"

Making GridView items square

萝らか妹 提交于 2019-12-17 02:59:09
问题 I would like the items of my GridView to be square. There are 2 columns and the items width is fill_parent (e.g. they take as much horizontal space as possible. The items are custom views. How do I make the items height to be equal to their variable width? 回答1: There is a simpler solution when GridView columns are stretched. Just override the onMeasure of the GridView item layout with... @Override public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure

Grid of images inside ScrollView

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 01:38:38
问题 I'm trying to create a screen with both text and images. I want the images to be laid out like a grid, as shown below, but I want them to have no scroll functionality other that the one provided by the surrounding ScrollView. An image will best illustrate my question: <ScrollView> <LinearLayout> <ImageView /> <TextView /> <GridView /> <TextView /> </LinearLayout> </ScrollView> What is the best way to make show a grid of a varying number of images, where the grid does not have scroll