0
在web應用程序[asp.net gridview]中,我想顯示gridvew沒有綁定數據,我的意思是我有頁腳模板那裏我保存文本框和按鈕,當用戶輸入並點擊添加然後數據將綁定到gridview,爲第一次[沒有數據時]只顯示頁腳。你能幫助我嗎,謝謝。有沒有提及參考。網格視圖頁腳模板?在Asp.net中?
在web應用程序[asp.net gridview]中,我想顯示gridvew沒有綁定數據,我的意思是我有頁腳模板那裏我保存文本框和按鈕,當用戶輸入並點擊添加然後數據將綁定到gridview,爲第一次[沒有數據時]只顯示頁腳。你能幫助我嗎,謝謝。有沒有提及參考。網格視圖頁腳模板?在Asp.net中?
創建具有相同的字段一個表[綁定gridivew]和數據綁定到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;
我想你可以使用;
<asp:GridView ID="gv1" runat="server" HeaderStyle-Font-Bold="true">
<EmptyDataTemplate>
<!-- your html template -->
</EmptyDataTemplate>
</asp:GridView>
希望這有助於