How do I access a particular row in asp Repeater and disable the buttons in it ? This program disables all the down buttons. I want to check if the userId exists in Database it should disable the up button and only the down button should be enabled.
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 (isOwner(userID) == true)
{
Button b = e.Item.FindControl("btnmoveup") as Button;
b.Enabled = false;
}
public bool isOwner(string user_ID)
{
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", user_ID);
SqlDataReader reader = cmd.ExecuteReader();
if (reader.HasRows)
{
return true;
}
else
{
return false;
}
connection.Close();
}
}