在Web应用程序[asp.net gridview]中,我想显示没有绑定数据的gridvew,我的意思是我有页脚模板,我保留文本框和按钮,当用户输入并单击添加然后数据将绑定到gridview,第一次[当没有数据时]只显示页脚。能帮帮我吗,谢谢。有没有提及参考。
答案 0 :(得分:0)
我认为你可以使用;
<asp:GridView ID="gv1" runat="server" HeaderStyle-Font-Bold="true">
<EmptyDataTemplate>
<!-- your html template -->
</EmptyDataTemplate>
</asp:GridView>
希望这个帮助
答案 1 :(得分:0)
创建一个具有相同字段的表[绑定gridview]并将数据绑定到gridview
DataTable dt = new DataTable();
DataColumn dc = new DataColumn("WeekNo", typeof(Int32));
dt.Columns.Add(dc);
dc = new DataColumn("Division", typeof(string));
dt.Columns.Add(dc);
dc = new DataColumn("Activity_Desc", typeof(string));
dt.Columns.Add(dc);
dc = new DataColumn("Projects", typeof(Int32));
dt.Columns.Add(dc);
dc = new DataColumn("MonDay", typeof(Int32));
dt.Columns.Add(dc);
dc = new DataColumn("TuesDay", typeof(Int32));
dt.Columns.Add(dc);
dc = new DataColumn("WednesDay", typeof(Int32));
dt.Columns.Add(dc);
dc = new DataColumn("ThursDay", typeof(Int32));
dt.Columns.Add(dc);
dc = new DataColumn("FriDay", typeof(Int32));
dt.Columns.Add(dc);
dc = new DataColumn("SaturDay", typeof(Int32));
dt.Columns.Add(dc);
dc = new DataColumn("SunDay", typeof(Int32));
dt.Columns.Add(dc);
dc = new DataColumn("Hid", typeof(Int32));
dt.Columns.Add(dc);
dc = new DataColumn("SubmitStatus", typeof(Int32));
dt.Columns.Add(dc);
dc = new DataColumn("TotalWeek", typeof(string));
dt.Columns.Add(dc);
dc = new DataColumn("Did", typeof(string));
dt.Columns.Add(dc);
//dc = new DataColumn("Curstatus", typeof(string));
//dt.Columns.Add(dc);
dc = new DataColumn("ActivityID", typeof(string));
dt.Columns.Add(dc);
dc = new DataColumn("ProjectId", typeof(string));
dt.Columns.Add(dc);
DataRow dr = dt.NewRow();
dr[0] = 0; dr[1] = 0; dr[2] = 0; dr[3] = 0; dr[4] = 0; dr[5] = 0; dr[6] = 0; dr[7] = 0; dr[8] = 0; dr[9] = 0; dr[10] = 0; dr[11] = 0; dr[12] = 0; dr[13] = 0;
dr[14] = 0; dr[15] = 0; dr[16] = 0; //dr[17]=0;
dt.Rows.Add(dr);
GridView.DataSource = dt;
GridView.DataBind();
GridView.Rows[0].Visible = false;