Ejemplo n.º 1
0
    protected void RepeaterComments_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName.CompareTo("CommentReject") == 0)
        {
            SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ShopConnectionString"].ConnectionString);
            SqlCommand    sqlCmd;

            try
            {
                TextBox answer = e.Item.FindControl("TextBoxAnswer") as TextBox;

                sqlCmd             = new SqlCommand("sp_commentVerification", sqlConn);
                sqlCmd.CommandType = CommandType.StoredProcedure;
                sqlCmd.Parameters.Add("@CommentId", SqlDbType.Int).Value   = e.CommandArgument.ToString();
                sqlCmd.Parameters.Add("@Status", SqlDbType.Int).Value      = 2;
                sqlCmd.Parameters.Add("@Answer", SqlDbType.NVarChar).Value = answer.Text;
                sqlConn.Open();
                sqlCmd.ExecuteNonQuery();
            }
            catch
            {
            }
            finally
            {
                sqlConn.Close();
            }

            RepeaterComments.DataBind();
        }

        if (e.CommandName.CompareTo("CommentVerify") == 0)
        {
            SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ShopConnectionString"].ConnectionString);
            SqlCommand    sqlCmd;

            try
            {
                TextBox answer = e.Item.FindControl("TextBoxAnswer") as TextBox;

                sqlCmd             = new SqlCommand("sp_commentVerification", sqlConn);
                sqlCmd.CommandType = CommandType.StoredProcedure;
                sqlCmd.Parameters.Add("@CommentId", SqlDbType.Int).Value   = e.CommandArgument.ToString();
                sqlCmd.Parameters.Add("@Status", SqlDbType.Int).Value      = 1;
                sqlCmd.Parameters.Add("@Answer", SqlDbType.NVarChar).Value = answer.Text;
                sqlConn.Open();
                sqlCmd.ExecuteNonQuery();
            }
            catch
            {
            }
            finally
            {
                sqlConn.Close();
            }

            RepeaterComments.DataBind();
        }
    }
Ejemplo n.º 2
0
 private void SetRepeater()
 {
     RepeaterDiv.Style.Add("height", dtComments.Rows.Count * 150 + 150 + "px");
     RepeaterComments.DataSource = dtComments;
     RepeaterComments.DataBind();
 }