我已将gridview绑定到Linq结果并将AutoGenerateColumns设置为true并为网格视图启用了Viewstate但仍然没有呈现,浏览器中的Html显示为空
<div></div>
奇怪的是,在文件系统中的ASP.NET开发服务器中它是可见的没有问题但是当我在Internet上托管它时它不是!!
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:asyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
<ContentTemplate >
<asp:GridView dir="rtl" ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" CellPadding="4" AutoGenerateColumns="true"
ForeColor="#333333" GridLines="Vertical" ViewStateMode="Enabled"
Width="917px" style=" padding-bottom:20px;" EnableViewState="True">
<AlternatingRowStyle BackColor="White" />
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White"
HorizontalAlign="Right" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
<br />
<br />
</ContentTemplate>
</asp:UpdatePanel>
顺便说一句,我也试图删除Ajax控件,但它没有解决问题
Linq代码非常复杂,但我可以告诉你这个
tmp = (From p In results Where p.ShowProduct
Select New With {.المادة = p.ProductName,
.السعر = If(p.Setting.ShowPrices, If(p.ShowPrice, (p.SellPrice * p.Setting.ConversionToDollar).ToString, " - "), " - "),
.الكمية = If(p.Setting.ShowCounts, If(p.ShowCount, CSng(p.Count) & " " & p.Unit, " - "), " - "),
.الصنف = p.Category,
.الوصف = p.Description,
.المنشأ = p.Manufacturer,
.المحل = If(p.Setting.ShowAddress,
If(p.Setting.ShowMobile,
p.Setting.NameOfShop & "/" & p.Setting.ShopAddress & "/" & p.Setting.Mobile,
p.Setting.NameOfShop & "/" & p.Setting.ShopAddress & "/ -"),
If(p.Setting.ShowMobile,
p.Setting.NameOfShop & "/ - /" & p.Setting.Mobile,
p.Setting.NameOfShop & "/ - / - ")),
.التاريخ = p.LastUpdate}).ToList.OrderByDescending(Function(n) n.GetType().GetProperty(GridViewSortExpression).GetValue(n, Nothing)).ToList
End If
ResultCount = results.Count
GridView1.DataSource = tmp
' GridView1.ViewStateMode = UI.ViewStateMode.Enabled
GridView1.DataBind()
我也尝试过这行代码
UpdatePanel1.Update()
请帮帮我
答案 0 :(得分:1)
我发现我的代码中没有错误,但Gridview没有呈现的原因是它是数据源是空的,因为虽然查询(结果)不是什么,但第二个查询(tmp)实际上是空的,因为条件(其中p.ShowProduct)我认为它是真的在检查Db后我发现该字段中的所有值都是空的。
谢谢