数据表在生产服务器上传后没有绑定,但在本地和实时服务器上完美运行是:IIS 7.0
下面是c#代码。
protected void FillGrid(string Paravalue)
{
try
{
bo.Para1 =Request.QueryString["ApplicationStatus"].ToString();pplicationStatus
bo.Para2 = Session["Userid"].ToString();// SubmittedBy
bo.Para3 = Paravalue;//Paravalue
DataTable dt = bl.Get_Applications(bo);
GridView1.DataSource = dt;
GridView1.DataBind();
if (dt.Rows.Count > 0)
{
lbl_texxt.Text = dt.Rows[0]["PositionTitle"].ToString();
}
else
{
lbl_texxt.Text = "No Data";
}
if (GridView1.Rows.Count > 0)
{
btnExport.Visible = true;
}
else
{
btnExport.Visible = false;
}
}
catch (Exception ex)
{
Console.WriteLine("er" + ex);
}
}
下面是Gridview代码。
<asp:GridView ID="GridView1" runat="server" DataKeyNames="PositionId"
AllowSorting="True" AlternatingRowStyle-CssClass="alt"
AutoGenerateColumns="False" CssClass="mGrid"
GridLines="None" HeaderStyle-CssClass="header"
HeaderStyle-Height="25px" PagerStyle-CssClass="pgr"
Width="900px" PageSize="50">
<Columns>
<asp:TemplateField HeaderText="#">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Width="30px" />
<ItemStyle CssClass="th" HorizontalAlign="Center" Width="30px" />
</asp:TemplateField>
<asp:BoundField DataField="PositionTitle" HeaderText="Position Title">
<ItemStyle CssClass="th" HorizontalAlign="Left" Width="250px" />
<HeaderStyle HorizontalAlign="Left" Width="250px" Height="25px" />
</asp:BoundField>
<asp:BoundField DataField="Openfor" HeaderText="Open for">
<ItemStyle HorizontalAlign="Left" Width="140px" />
<HeaderStyle HorizontalAlign="Left" Width="140px" Height="25px" />
</asp:BoundField>
<asp:BoundField DataField="Positions" HeaderText="Total Position(s)">
<ItemStyle HorizontalAlign="Center" Width="140px" />
<HeaderStyle HorizontalAlign="Left" Width="140px" Height="25px" />
</asp:BoundField>
<asp:TemplateField HeaderText="Location">
<ItemTemplate>
<asp:Label ID="lbl_state" runat="server" Text='<%# Eval("State") %>'></asp:Label>
-
<asp:Label ID="lbl_City" runat="server" Text='<%# Eval("City") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle Width="200px" HorizontalAlign="Left" VerticalAlign="Middle" />
<ItemStyle Width="200px" HorizontalAlign="Left" VerticalAlign="Middle" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Count">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" CssClass="pr_list_count2_action" runat="server" Text='<%# Eval("Count") %>' onClick="ViewApplications">0</asp:LinkButton>
</ItemTemplate>
<HeaderStyle Width="140px" HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle Width="140px" HorizontalAlign="Center" VerticalAlign="Middle" Font-Bold="true" Font-Underline="true" CssClass="grid_row1_action" />
</asp:TemplateField>
<asp:TemplateField HeaderText="PositionId" Visible="false">
<ItemTemplate>
<asp:Label ID="lbl_ProjectID" runat="server" Text='<%# Eval("PositionId") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle CssClass="pgr" />
<AlternatingRowStyle CssClass="alt" />
<EmptyDataTemplate>
<center>
<asp:LinkButton ID="lnkbtn_nodata" runat="server" Text="No applications pending for review." OnClick="lnkbtn_nodata_Click"></asp:LinkButton>
</center>
</EmptyDataTemplate>
</asp:GridView>
我将实时数据库恢复到本地并检查工作正常,显示32000万个数据到本地主机的gridview中。还有一件事是在显示No Data
后花费时间在实时服务器上加载。同时保持try catch块并获取'No Data'和ApplicationStatus查询字符串值更改,然后显示数据低于10000,000条记录。
答案 0 :(得分:0)
我看到你的问题,你的编码没有错误。但是您可能有可能在用于填充数据表的类中错误地定义了连接字符串。因此,请在同一页面上写下所有内容,不要使用类一段时间来查找错误。您可以使用以下代码。它可以帮助您找到错误。
protected void FillGrid(string Paravalue)
{
try
{
bo.Para1 = Request.QueryString["ApplicationStatus"].ToString();//ApplicationStatus
bo.Para2 = Session["Userid"].ToString();// SubmittedBy
bo.Para3 = Paravalue;//Paravalue
//DataTable dt = bl.Get_Applications(bo);
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["your connection name"].ConnectionString);
DataTable dt = new DataTable();
SqlCommand cmd = new SqlCommand("your query or procedure name", con);
cmd.Parameters.AddWithValue("Para1", bo.Para1);
cmd.Parameters.AddWithValue("Para1", bo.Para1);
cmd.Parameters.AddWithValue("Para1", bo.Para1);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
if (dt.Rows.Count > 0)
{
lbl_texxt.Text = dt.Rows[0]["PositionTitle"].ToString();
}
else
{
lbl_texxt.Text = "No Data";
}
if (GridView1.Rows.Count > 0)
{
btnExport.Visible = true;
}
else
{
btnExport.Visible = false;
}
}
catch (Exception ex)
{
Console.WriteLine("er" + ex);
}
}
答案 1 :(得分:0)
当前的GrivView-Paging将由对象数据源调整,并根据Pageindex(按需)加载记录,并从Gridview中删除分页。