Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;

public partial class _Default : System.Web.UI.Page
{
   string s1 = ConfigurationManager.ConnectionStrings["mlaConnectionString"].ToString();
   protected void Page_Load(object sender, EventArgs e)
   {
      if (!Page.IsPostBack)
      {
         BindRepeater();
      }
   }
   private void BindRepeater()
   {
      SqlConnection SqlCnn = new SqlConnection(s1);
      SqlCommand SqlCmd = new SqlCommand("select * from mla_video", SqlCnn);
      SqlDataAdapter SqlAd1 = new SqlDataAdapter(SqlCmd);
      DataSet ds = new DataSet();
      SqlAd1.Fill(ds, "mla_video");
      RepterDetails.DataSource = ds;
      RepterDetails.DataBind();
   }
      
   protected void dlNewVideo_SelectedIndexChanged(object sender, EventArgs e)
   {
   }
   protected void RepterDetails1_ItemCommand(object source, RepeaterCommandEventArgs e)
   {
      LinkButton lnkDelete = (LinkButton)e.Item.FindControl("lnkDelete");
      Label lbl_title = (Label)e.Item.FindControl("lbl_text");

      Label lbl_deseription = (Label)e.Item.FindControl("lbl_deseription");

      Label lbl_date = (Label)e.Item.FindControl("lbl_date");

      Image imgDB = (Image)e.Item.FindControl("imgDB");

      CheckBox chk = (CheckBox)e.Item.FindControl("chk");
      CheckBox chkall = (CheckBox)e.Item.FindControl("chkall");
   }

   if (e.CommandName == "delete")
   {
      SqlConnection SqlCnn = new SqlConnection(s1);
      SqlCommand SqlCmd = new SqlCommand("delete mla_image 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();
   }
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
   foreach (RepeaterItem Item in RepterDetails.Items)
   {
      CheckBox chk = (CheckBox)Item.FindControl("chk");
      Label lbl_title = (Label)Item.FindControl("lbl_title");

      if (chk.Checked)
      {
         SqlConnection SqlCnn = new SqlConnection(s1);
         SqlCommand SqlCmd = new SqlCommand("delete mla_video where Title=@title", SqlCnn);
         SqlCmd.Parameters.Add("@title", SqlDbType.VarChar).Value = lbl_title.Text;
         SqlCmd.Connection = SqlCnn;
         SqlCnn.Open();
         SqlCmd.ExecuteNonQuery();
         SqlCnn.Close();
      }
   }
   BindRepeater();
}
}

XML
<asp:Repeater ID="RepterDetails" runat="server"
            onitemcommand="RepterDetails1_ItemCommand" >
        <HeaderTemplate>
            <table cellspacing="0" cellpadding="0" bgcolor="#e6e5e5" style="width: 650px">
                <tr>
                    <td height="30px" bgcolor="#ffffff">
                    </td>
                </tr>
                <tr>
                    <td class="tourname_heading12" align="center">
                        <asp:CheckBox ID="chkall" runat="server" EnableViewState="true"  CssClass="chkHeader" OnClick="checkAll(this)"/>
   Delete Image</td>
                </tr>
            </table>
        </HeaderTemplate>
        <ItemTemplate>
            <table style="border-top:1px dotted #3b5998; width:650px">
                <tr>
                    <td align="right" style="width:650px">
                    </td>
                </tr>
                <table>
                    <tr>
                        <td rowspan="3" style="margin:1px 1px 1px 1px">
                            <asp:CheckBox ID="chk" runat="server" EnableViewState="true"  CssClass="chkItem"/>
                              <iframe  runat="server" id="detail" src='<%#Eval("Vlink") %>'  height="150px" width="250px"></iframe>
                        </td>
                        <td>
                            <table style=" width:500px" >
                                <tr>
                                    <td >
                                        <asp:Label ID="lbl_title" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Title")%>' Font-Bold="true"></asp:Label>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="lbl_deseription" runat="server"  class="more"  Width="450px" Text='<%# DataBinder.Eval(Container.DataItem, "Deseription")%>'></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <table style="border-top:1px dotted #3b5998;border-bottom:1px solid #3b5998; width:500px" >
                                <tr>
                                    <td >
                                        <asp:label ID="lbl_id" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ID")%>'  Font-Bold="true" Visible="false"></asp:Label>
                                    </td>
                                    <td >
                                        Date:<asp:Label ID="lbl_date" runat="server" Font-Bold="true" Text='<%#Eval("Date") %>'/>
                                    </td>
                                    <td align="right">
                                        <asp:LinkButton ID="lnkDelete" runat="server" CommandName="delete" Text="Delete" OnClientClick='javascript:return confirm("Are you sure you want to delete?")'
            CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ID") %>'  CssClass="item_button"></asp:LinkButton>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3">
                            &nbsp;</td>
                    </tr>
                </table>
        </ItemTemplate>
        <FooterTemplate>
            <table width="500px" style="background-color:White;height:10px">
                <tr style="height:10px">
                    <td>
                    </td>
                </tr>
                <tr>
                    <td>
                    </td>
                    <td align="center">
                        <asp:LinkButton ID="lnkDelSelected" ForeColor="white" runat="server" Text="Delete Selected" onclick="LinkButton1_Click" OnClientClick='javascript:return confirm("Are you sure you want to delete?")' CssClass="item_button"></asp:LinkButton>
                    </td>
                </tr>
            </Table>
        </FooterTemplate>
    </asp:Repeater>
Posted
Updated 19-May-14 2:02am
v2
Comments
ZurdoDev 19-May-14 7:12am    
What is your error?
Member 10678779 19-May-14 7:37am    
Image imgDB = (Image)e.Item.FindControl("imgDB");

how to use iframe in that code
ZurdoDev 19-May-14 7:40am    
That is not an error. Nor does that include an iframe.
Member 10678779 19-May-14 7:55am    
bro u can send me the sample coding for update and delete video coide plz
ZurdoDev 19-May-14 7:56am    
No.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900