我接受用戶標識並想檢查是否有任何具有相同標識的項目所有者。如果存在項目所有者,我應該只啓用「下移」按鈕並禁用所有其他按鈕。如果存在管理員,則所有按鈕均啓用,而不是第一次上移,最後一次下移。 我想禁用所有的按鈕,而不是其中的POwner與用戶ID相同! (如果POwner是相同的用戶名只能下移按鈕應該啓用。根據登錄用戶禁用按鈕
public void Repeater1_ItemDatabound(Object Sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
String userID = User.Identity.Name.Split('\\')[1];
if (setvisibility(userID) == true) //Check if the person is Admin all buttons work
{
if (e.Item.ItemIndex == 0)
{
Button b = e.Item.FindControl("btnmoveup") as Button;
b.Enabled = false;
}
DataView view = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
DataTable result = view.ToTable();
if (e.Item.ItemIndex == (result.Rows.Count) - 1)
{
Button b2 = e.Item.FindControl("btnmovedown") as Button;
b2.Enabled = false;
}
}
else // Check if Project Owner (POwner exists) Check if userID exists in POwner
{
using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["ctd_priority_dbConnectionString"].ConnectionString))
{
connection.Open();
SqlCommand cmd = new SqlCommand("Select POwner from Projects WHERE POwner = @userid", connection);
cmd.Parameters.AddWithValue("@userid", userID);
SqlDataReader reader = cmd.ExecuteReader();
你的問題是什麼? – 2012-06-28 13:28:40
與asp-classic完全沒有關係 – ulluoink
我想禁用所有按鈕,而不是其中的POwner與userID相同! – Pradit