1

我已将 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()

请帮我

4

1 回答 1

1

我发现我的代码中没有错误,但是没有呈现 Gridview 的原因是它是数据源是空的,因为虽然查询(结果)不是什么,但第二个查询(tmp)实际上是空的,因为条件(其中 p.ShowProduct) 我认为它是 True 在检查 Db 后,我发现该字段中的所有值都是 Null 。

谢谢

于 2012-09-29T13:28:34.327 回答