title: List view method not working
body: <p>I am using a lisview and binding data with the help of ItemDataBound.</p>
  
  <p><strong>Problem :</strong> when I click on a label it show data related to it but when I click on other data it shows data related to 1st and 2nd items and this continues till end.</p>
  
  <p>I tried to clear list using  <code>listviedo.Items.Clear();</code>  in <strong>SelectedIndexChanging</strong> method but this didn't works.</p>
  
  <p>Help me to solve this.</p>
  
  <p><strong>aspx.cs code</strong></p>
  
  <pre><code>public string getvalue(int ID)
  {
  Tbl_Multiple_Video_Master obj = DB.Tbl_Multiple_Video_Master.Single(p =&gt; p.VID == ID);
  if (obj.IsUrl == false)
  {
  string Link = "&lt;iframe id=\"paidVideo\" src=\"https://de122v0opjemw.cloudfront.net/utils/embedplayer.php?enablejsapi=1&amp;video=" + obj.Name+"\" height=\"300\" width=\"500\"&gt;&lt;/iframe&gt;";
  return Link;
  }
  else
  {
  return "&lt;iframe id=\"cartoonVideo\" width=\"560\" height=\"315\"  src=\"" + obj.Name + "\" frameborder=\"0\" allowfullscreen &gt;&lt;/iframe&gt;";
  }
  }
  protected void listviedo_ItemCommand(object sender, ListViewCommandEventArgs e)
  {
  Literal lblvedio = (Literal)e.Item.FindControl("lblvedio");
  if (e.CommandName == "Select")
  {
  int ID = Convert.ToInt32(e.CommandArgument);
  Database.Tbl_Multiple_Video_Master obj = DB.Tbl_Multiple_Video_Master.Single(p =&gt; p.VID == ID);
  if (obj.IsUrl == false)
  {
  lblvedio.Visible = true;
  string Link = "&lt;iframe id=\"paidVideo\" src=\"https://de122v0opjemw.cloudfront.net/utils/embedplayer.php?enablejsapi=1&amp;video=" + obj.Name + "\" height=\"300\" width=\"500\"&gt;&lt;/iframe&gt;";
  }
  else
  {
  lblvedio.Visible = true;
  string Link = "&lt;iframe id=\"cartoonVideo\" width=\"560\" height=\"315\"  src=\"" + obj.Name + "\" frameborder=\"0\" allowfullscreen &gt;&lt;/iframe&gt;";
  }
  }
  }
  protected void listviedo_ItemDataBound(object sender, ListViewItemEventArgs e)
  {
  Label lblid = (Label)e.Item.FindControl("lblid");
  LinkButton linkresuume = (LinkButton)e.Item.FindControl("linkresuume");
  int ID = Convert.ToInt32(lblid.Text);
  Database.Tbl_Multiple_Video_Master objcar = DB.Tbl_Multiple_Video_Master.Single(p =&gt; p.VID == ID);
  }
  protected void listviedo_SelectedIndexChanged(object sender, EventArgs e)
  {
  if (listviedo.SelectedIndex &gt; -1)
  {
  SelectedVideo.Text = "Selected Video is : " + listviedo.SelectedValue.ToString();
  }
  else
  {
  SelectedVideo.Text = "Please Select a Video" + listviedo.SelectedIndex.ToString();
  }
  }
  protected void listviedo_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
  {
  listviedo.Items.Clear();
  }
  
  protected void listviedo_ItemCommand(object sender, ListViewCommandEventArgs e)
  {
  Literal lblvedio = (Literal)e.Item.FindControl("lblvedio");
  if (e.CommandName == "Select")
  {
  int ID = Convert.ToInt32(e.CommandArgument);
  Database.Tbl_Multiple_Video_Master obj = DB.Tbl_Multiple_Video_Master.Single(p =&gt; p.VID == ID);
   if (obj.IsUrl == false)
   {
  lblvedio.Visible = true;
   string Link = "&lt;iframe id=\"paidVideo\" src=\"https://de122v0opjemw.cloudfront.net/utils/embedplayer.php?enablejsapi=1&amp;video=" + obj.Name + "\" height=\"300\" width=\"500\"&gt;&lt;/iframe&gt;";
  }
  else
  {
  lblvedio.Visible = true;
  string Link = "&lt;iframe id=\"cartoonVideo\" width=\"560\" height=\"315\"  src=\"" + obj.Name + "\" frameborder=\"0\" allowfullscreen &gt;&lt;/iframe&gt;";
  }
  }
  }
  protected void listviedo_ItemDataBound(object sender, ListViewItemEventArgs e)
  {
  Label lblid = (Label)e.Item.FindControl("lblid");
  LinkButton linkresuume = (LinkButton)e.Item.FindControl("linkresuume");
  int ID = Convert.ToInt32(lblid.Text);
  Database.Tbl_Multiple_Video_Master objcar = DB.Tbl_Multiple_Video_Master.Single(p =&gt; p.VID == ID);
  }
  protected void listviedo_SelectedIndexChanged(object sender, EventArgs e)
  {
  if (listviedo.SelectedIndex &gt; -1)
  {
  SelectedVideo.Text = "Selected Video is : " + listviedo.SelectedValue.ToString();
  }
  else
  {
  SelectedVideo.Text = "Please Select a Video" + listviedo.SelectedIndex.ToString();
  }
  }
  protected void listviedo_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
  {
  listviedo.Items.Clear();
  }
  </code></pre>
  
  <p><strong>aspx code</strong></p>
  
  <pre><code>&lt;asp:ListView ID="listviedo" runat="server"
                                  DataKeyNames="VideoName" 
                                  OnItemCommand="listviedo_ItemCommand" 
                                  OnItemDataBound="listviedo_ItemDataBound"
                                  OnSelectedIndexChanged="listviedo_SelectedIndexChanged"
                                  OnSelectedIndexChanging="listviedo_SelectedIndexChanging" &gt;
  
                                  &lt;ItemTemplate&gt;
  
                                      &lt;div&gt;
                                          &lt;table&gt;
                                              &lt;tr style="border:solid;"&gt;
                                                  &lt;td style="border:solid;"&gt;
                                                      &lt;asp:Literal ID="lblvedio"  runat="server" Visible="false" Text='&lt;%#   getvalue(Convert.ToInt32(Eval("VID")))%&gt;'&gt;&lt;/asp:Literal&gt;
                                                  &lt;/td&gt;
                                              &lt;/tr&gt;
                                              &lt;tr&gt;
                                                  &lt;td style="border:solid;"&gt;
                                                      &lt;span&gt;
                                                          &lt;asp:LinkButton runat="server" ID="lnkname" CommandName="Select" CommandArgument='&lt;%# Eval("VID") %&gt;'&gt;
                                                              &lt;asp:Label ID="lblname" runat="server" Text='&lt;%# Eval("VideoName")%&gt;'&gt;&lt;/asp:Label&gt;
                                                              &lt;asp:Label ID="lblid" runat="server" Visible="false" Text='&lt;%# Eval("VID")%&gt;'&gt;&lt;/asp:Label&gt;
                                                          &lt;/asp:LinkButton&gt;
                                                      &lt;/span&gt;
                                                  &lt;/td&gt;
                                              &lt;/tr&gt;
                                          &lt;/table&gt;
                                      &lt;/div&gt;
  
                                  &lt;/ItemTemplate&gt;
  
                    &lt;/asp:ListView&gt;
  </code></pre>