在空网格上显示 gridview 页脚? [英] Show gridview footer on empty grid?

查看:20
本文介绍了在空网格上显示 gridview 页脚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想知道在 gridview 为空时显示用于数据输入的 gridview 页脚的最佳和最简单的方法是什么?

just wanted to know what is the best and easiest way to show a gridview footer for data entry even when the gridview is empty ?

推荐答案

将数据源设置为绑定到 GridView 的对象类型,其中一个对象填充空值,然后隐藏该 DataRow.

Set your datasource to the type of object you're binding to the GridView with one object filled with empty values, then hide that DataRow.

由于您使用的是数据表...

Since you're using a datatable...

DataTable dt = new DataTable();

// Define all of the columns you are binding in your GridView
dt.Columns.Add("AColumnName");
...
...

DataRow dr = dt.NewRow();
dt.Rows.Add(dr);

myGridView.DataSource = dt;
myGridView.DataBind();

这篇关于在空网格上显示 gridview 页脚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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