January 13, 2017

ASP.NET Repeater - show part of data in column


Text='<%# Convert.ToString(Eval("description")).Substring(0, 20) %>'

Related Article :- Deleteing seleted items from Repeator Control

January 10, 2017

Deleteing seleted items from Repeator Control

   foreach (RepeaterItem ri in RepDetails.Items)
        {

            CheckBox item_check = (CheckBox)ri.FindControl("chkmessages");
            Label txt_id = (Label)ri.FindControl("lblMessageID");

            if (item_check.Checked)
            {
                using (SqlConnection con = new SqlConnection("Data Source=BCILGGN45\\SQLEXP2012;Initial Catalog=SampleDataBase;User ID=sa;Password=sql@2012"))
                {
                    using (SqlCommand cmd = new SqlCommand("[USP_MESSAGEMASTER]", con))
                    {
                            
                cmd.CommandType = CommandType.StoredProcedure;
                con.Open();
                cmd.Parameters.Add("@Type", SqlDbType.VarChar, 50).Value = "DELETE";
                cmd.Parameters.Add("@MessageID", SqlDbType.Int).Value = Convert.ToInt16(txt_id.Text);
                cmd.ExecuteNonQuery();
                
                    }
                }
            }
        }