我有以下代码。我试图让gridview行宽保持永久性而不会在控件不可见时收缩。当控件可见时,该行看起来很好,当它不可见时,该行与gridview中的下一行组合。有任何想法吗?
if (File.Exists(@"\\10.10.1.45\public\hdma\" + NDCNumber + ".pdf"))
{
e.Row.Cells[2].Visible = true;
HDMALink.NavigateUrl = @"\\10.10.1.45\public\hdma\" + NDCNumber + ".pdf";
}
else
{
e.Row.Cells[2].Visible = false;
}
HTML
<Columns>
<asp:HyperLinkField Target="_blank" DataNavigateUrlFields="NDCNumber" Text="D" HeaderStyle-HorizontalAlign ="Left" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="1%" ItemStyle-ForeColor="#284775" ItemStyle-BorderStyle="None" />
<asp:HyperLinkField Target="_blank" DataNavigateUrlFields="NDCNumber" HeaderText="Print" HeaderStyle-HorizontalAlign="Left" Text="S" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="6%" ItemStyle-BorderStyle="None" />
<asp:HyperLinkField Target="_blank" HeaderText="HDMA" Text="H" ItemStyle-Width="1%" ItemStyle-HorizontalAlign="Center" ItemStyle-ForeColor="#284775" />
<asp:BoundField DataField="NDCNumber" HeaderText="NDC Number" HeaderStyle-HorizontalAlign ="Center" ItemStyle-Width="12%" ItemStyle-HorizontalAlign="Center" />
<asp:HyperLinkField DataTextField="ProductName" HeaderText="Product Name" HeaderStyle-HorizontalAlign ="Center" ItemStyle-Width="35%" ItemStyle-BorderStyle="None" />
<asp:BoundField DataField="Strength" HeaderStyle-HorizontalAlign="Center" HeaderText="Strength" ItemStyle-Width="20%" ItemStyle-BorderStyle="None" />
<pac:BoundButtonField CommandName="Edit" HeaderText="" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" NavigateUrl="~/general.aspx" ItemStyle-Width="5%" ItemStyle-BorderStyle="None" />
<pac:BoundButtonField CommandName="Delete" HeaderText="Delete" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="5%" ConfirmMsg = "Are you sure you wish to delete this product?" ItemStyle-BorderStyle="None" />
答案 0 :(得分:0)
使用绝对值而不是百分比来设置宽度。
ItemStyle-Width="60px"