2
我的頁面有什麼問題? 當我試圖加載我的網頁。它返回到一個空白頁面。怎麼了?頁面加載正在返回空白頁
請查看我的代碼,它會在瀏覽器中返回null或空白頁。
它甚至沒有顯示任何錯誤。正當我嘗試加載它。我的瀏覽器上顯示全部空白的白色顯示。
這裏是我的代碼:
<%@ Page Language="C#" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace = "System.Data.SqlClient" %>
<script runat="server" type="css">
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bind();
}
}
protected void bind()
{
PendingRecordsGridview.DataSourceID = "";
PendingRecordsGridview.DataSource = sd1;
PendingRecordsGridview.DataBind();
}
protected void PendingRecordsGridview_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "accept")
{
Session["id"] = e.CommandArgument.ToString();
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
con.Open();
SqlCommand cmd1 = new SqlCommand("INSERT INTO tb2 (id, name) SELECT id, name FROM tb1 where id='"+Session["id"].ToString()+"'", con);
SqlCommand cmd2 = new SqlCommand("delete from tb1 where id='"+Session["id"].ToString()+"'", con);
cmd1.ExecuteNonQuery();
cmd2.ExecuteNonQuery();
bind();
}
}
</script>
<form id="form1" runat="server">
<asp:GridView ID="PendingRecordsGridview" runat="server" AutoGenerateColumns="False" DataKeyNames="id" onrowcommand="PendingRecordsGridview_RowCommand" DataSourceID="sd1">
<Columns>
<asp:templatefield HeaderText="Accept">
<ItemTemplate>
<asp:Button CommandArgument='<%# Bind("id") %>' ID="Button1" runat="server" CausesValidation="false" CommandName="accept" Text="Accept" />
</ItemTemplate>
</asp:templatefield>
<asp:templatefield HeaderText="name" SortExpression="name">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("name") %>'>
</asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("name") %>'>
</asp:Label>
</ItemTemplate>
</asp:templatefield>
<asp:templatefield HeaderText="id" SortExpression="id">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("id") %>'>
</asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("id") %>'>
</asp:Label>
</ItemTemplate>
</asp:templatefield>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="sd1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [tb1]">
</asp:SqlDataSource>
</form>
什麼是'sd1'?它來自哪裏?它是空的嗎? – Oded
這段代碼被插入的頁面名稱是什麼?您確定在應用程序啓動後在瀏覽器窗口中輸入了頁面的名稱嗎?像'http:// localhost:8383/MyPage.aspx' –
@O ow我有你的想法。我會首先提供一些信息。對不起我的不好:)但當發生同樣的錯誤。我要發佈它。馬上回來:) –