尽管asp.net中的网格视图中没有记录,但默认显示页脚行
全部。可能这个问题又补充到这里了,还请见谅。我想表达这个场景。
出色地!
我有一个 ASP.NET Web 应用程序,它具有与数据库绑定的网格视图控件以显示记录。但。与往常一样,根据网格视图控件的性质,如果数据库/表中没有记录,那么我将显示空白网格。当我方便用户时,他可以通过此网格视图添加、编辑、更新记录。我将所有文本框放在页脚行中。但由于表中没有记录,它呈现空白网格。
我作为数据源提供给 grod 视图的是用户列表 (List
。
我想显示此页脚行,尽管数据库中没有记录。
all. May this question again added here , so please forgive me . i wanted to express the scenario.
well!
I have an asp.net web application that having the grid view control binding with database to show the records. but. as usual by nature of the grid view control , if there is no records in the database / table then i would show me blank grid. where as i facilitate to user,m he can add, edit,update the record through this grid view. I placed all the text boxes in footer row. but since no records in table it rendering blank grid.
where as i am giving as datasource to grod view is List of users (List<User>)
.
I want to show this footer row , though there is no records in the database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以做一件事。正如你所说,你在这里使用列表
然后在您填充网格的函数中检查您的列表是否有任何对象?通过其计数属性。如果计数为零,则在列表中添加一个对象。但使用一些带有默认值的属性扩展此对象,该默认值不属于数据库但属于应用程序级别。现在,在行数据绑定命令中检查当前行对象的此扩展属性的某些约束。还要检查行的类型。 except footer 使满足条件的行可见为 false。尽管您的数据库为空,但这就是您只能得到的页脚行。
如果您使用数据表作为数据源,则在数据表中添加一个空白数据行。但保持一定的约束来检查这是空白行。
You can do one thing. as you said you are using here List
then in the function where you are filling the grid check that is your List having any object ? by its count property. if there is zero count the add a object in list. but extend this object with some property with some default value which does not belong from database but belongs from application level. now in your row data bound command check certain constraints against this extended property for current row object.also check type of the row. except footer make visible false the row which satisfy the condition. thats all you will get only footer row there though your database is empty.
And if you are using the datatable as datasource then add a blank datarow in your datatable. but keep certain constraint to check this is blank row.
您可以在此处了解如何子类化 GridView 以添加所需的功能: http://mattberseth .com/blog/2007/07/how_to_show_header_and_footer.html
Here you can read how you can subclass GridView to add the functionality you need: http://mattberseth.com/blog/2007/07/how_to_show_header_and_footer.html