0

在 web 应用程序 [asp.net gridview] 中,我想显示不绑定数据的 gridvew,我的意思是我有页脚模板,当用户输入并单击添加时,我保留了文本框和按钮,然后数据将第一次绑定到 gridview [当没有数据时]应该只显示页脚。你能帮帮我吗,谢谢。有没有参考可以参考。

4

2 回答 2

0

我认为你可以使用;

<asp:GridView ID="gv1" runat="server" HeaderStyle-Font-Bold="true">   
<EmptyDataTemplate>
<!-- your html template -->
</EmptyDataTemplate> 
</asp:GridView>

希望这有帮助

于 2012-04-05T07:15:37.440 回答
0

创建一个具有相同字段的表[绑定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;
于 2012-05-03T03:37:57.400 回答