2
我有一個sqldatasource列表視圖和鏈接按鈕不會被解僱,但如果我使用作爲數據源一個字符串數組,他們會被解僱。我在代碼中丟失了什麼嗎?sqldatasource問題
aspx頁面:
<%
SqlDataSourceArticoleUser.ConnectionString = conn;
SqlDataSourceArticoleUser.SelectCommand = "SELECT top 10 * FROM (SELECT ROW_NUMBER() OVER (ORDER BY id desc) AS Row, * FROM articole) AS EMP WHERE Row >" + pag + " and username='" + user + "'";
%>
<asp:ListView ID="ListViewArticoleUser" runat="server" DataSourceID="SqlDataSourceArticoleUser">
<LayoutTemplate>
<ul>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</ul>
</LayoutTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButtonEditArticolEdit" runat="server" Text="edit" CommandName="articoledit"></asp:LinkButton>
<asp:LinkButton ID="LinkButtonStergeArticolEdit" runat="server" Text="sterge" CommandName="articolsterge"></asp:LinkButton>
</ItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SqlDataSourceArticoleUser" runat="server"></asp:SqlDataSource>
aspx.cs頁:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
SqlDataSourceArticoleUser.DataBind();
}
}
protected void Page_Init(object sender, EventArgs e)
{
ListViewArticoleUser.ItemCommand += new EventHandler<ListViewCommandEventArgs>(ListViewArticoleUser_EventHandler);
}
protected void ListViewArticoleUser_EventHandler(object sender, ListViewCommandEventArgs e)
{
if (e.CommandName == "articolsterge")
{
}
}
另外,提醒我在該網站上使用的用戶名註冊:「;刪除* from articole; – Robaticus 2011-01-11 19:23:19