我正在动态创建ASP.net Gridview,即运行时。在这些列中,我需要将一列添加为HTML。
下面是创建动态表格视图的代码。我想要 将一栏中的数据设置为HTML。我也想将网格的宽度设置为100%。
当网格视图没有任何数据时,网格将缩小到最小宽度。有没有办法设置gridciew的最小宽度。
SearchGridview = new GridView();
SearchGridview.AllowPaging = true;
SearchGridview.PageSize = 20;
SearchGridview.AllowSorting = true;
SearchGridview.AlternatingRowStyle.CssClass = "GridAlternateRow";
SearchGridview.RowStyle.CssClass = "GridRow";
SearchGridview.PageIndexChanging += searchGridview_PageIndexChanging;
DataTable searchDataTable = new DataTable();
searchDataTable.Columns.AddRange(new DataColumn[6]
{
new DataColumn("COl1", typeof (string)),
new DataColumn("col2", typeof (string)),
new DataColumn("COl3", typeof (string)),
new DataColumn("Col4", typeof (string))
});
SearchGridview.DataSource = GetData();
SearchGridview.DataBind();