数据表在生产服务器上传后未绑定,但在本地运行良好
Datatable is not binding after uploading in production server but working perfectly in local
数据表在生产服务器上传后未绑定,但在本地和实时服务器中运行良好 is: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>
我将实时数据库恢复到本地并检查工作正常,将 3200 万数据显示到本地主机的 gridview 中。还有一件事它在显示 No Data
后需要时间加载实时服务器。由于还保留了 try catch 块并获取 'No Data' 和 ApplicationStatus 查询字符串值更改,因此数据显示低于 1000 万条记录。
我看到你的问题了,你的编码没有错误。但是您用于填充数据表的 class 中的连接字符串可能有错误的定义。所以请将所有内容都写在同一页上,不要在某些时候使用 class 来查找错误。您可以使用以下代码。它可能会帮助您找到错误。
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);
}
}
当前的 GridView-Paging 将通过对象数据源进行调整,并根据 Pageindex(按需)加载记录并从 Gridview 中删除分页。
数据表在生产服务器上传后未绑定,但在本地和实时服务器中运行良好 is: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>
我将实时数据库恢复到本地并检查工作正常,将 3200 万数据显示到本地主机的 gridview 中。还有一件事它在显示 No Data
后需要时间加载实时服务器。由于还保留了 try catch 块并获取 'No Data' 和 ApplicationStatus 查询字符串值更改,因此数据显示低于 1000 万条记录。
我看到你的问题了,你的编码没有错误。但是您用于填充数据表的 class 中的连接字符串可能有错误的定义。所以请将所有内容都写在同一页上,不要在某些时候使用 class 来查找错误。您可以使用以下代码。它可能会帮助您找到错误。
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);
}
}
当前的 GridView-Paging 将通过对象数据源进行调整,并根据 Pageindex(按需)加载记录并从 Gridview 中删除分页。