
Hi Saranya Boopathi ,
Yes it is possible to edit as well as delete the data in Repeater control,
SImply add one column for CheckboxList in your Repeater control . After that when a User can select those checkbox, Get the Row value of that selected check box By using RowCommand evnt.Please Review the following mentined sample code for your reference .
if (e.CommandName == "update")
{
SqlConnection SqlCnn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
SqlCommand SqlCmd = new SqlCommand("update CPMEMBERS set Member=@Member, UpdatedType=@UpdatedType where id=@ID", SqlCnn);
SqlCmd.Parameters.Add("@Member", SqlDbType.VarChar).Value = txtName.Text;
SqlCmd.Parameters.Add("@UpdatedType", SqlDbType.VarChar).Value = ddlType.SelectedItem.Text;
SqlCmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = e.CommandArgument;
try
{
SqlCnn.Open();
SqlCmd.ExecuteNonQuery();
}
catch (Exception ex)
{
ex.Message.ToString();
}
finally
{
if (SqlCnn.State == ConnectionState.Open)
SqlCnn.Close();
}
BindRepeater();
}
if (e.CommandName == "delete")
{
SqlConnection SqlCnn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
SqlCommand SqlCmd = new SqlCommand("delete CPMEMBERS where id=@ID", SqlCnn);
SqlCmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = e.CommandArgument;
try
{
SqlCnn.Open();
SqlCmd.ExecuteNonQuery();
}
catch (Exception ex)
{
ex.Message.ToString();
}
finally
{
if (SqlCnn.State == ConnectionState.Open)
SqlCnn.Close();
}
BindRepeater();
}
Saranya Boopathi, if this helps please login to Mark As Answer. | Alert Moderator