Working with Datalist in asp.net?
<p>i place a datalist in my project in that i place a link button when i click on that link button a panel will open in that row with a textbox and a button. it is working fine but my problem is if i click on one  link button of a row panel will open, when i click on second row link button the sencond row panel is opening but first row panel is not closing. I think you get my point owhter wise i will explain again  this is my code check out</p>

<pre><code>&lt;form id="form1" runat="server"&gt;
&lt;div&gt;
&lt;asp:DataList ID="Mydatalist" runat ="Server"
              OnItemCommand="Mydatalist_ItemCommand" &gt;
  &lt;ItemTemplate &gt;
    &lt;table &gt;
      &lt;tr&gt;
        &lt;td&gt;
          &lt;asp:Label ID="lblcouname" runat ="server"
                     Text ='&lt;%# Eval("country_name") %&gt;'&gt;&lt;/asp:Label&gt;
        &lt;/td&gt;
        &lt;td&gt; 
          &lt;asp:LinkButton ID="lnkrepl" Text="reply"
                          CommandName ="reply" runat ="server"
                          CommandArgument ='&lt;%# Eval("country_id") %&gt;'&gt;
          &lt;/asp:LinkButton&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
    &lt;div&gt;
       &lt;asp:Panel ID="mypane" runat ="Server" Visible ="false"  &gt;
         &lt;asp:TextBox ID="txtpane" runat ="Server" &gt;&lt;/asp:TextBox&gt;&lt;br /&gt;
         &lt;asp:Button ID="btnInsert" runat="Server" Text ="Insert" /&gt;
       &lt;/asp:Panel&gt;
    &lt;/div&gt;
  &lt;/ItemTemplate&gt;
&lt;/asp:DataList&gt;
&lt;/div&gt;
&lt;/form&gt;
</code></pre>

<p>Code behind:</p>

<pre><code>public partial class Datlist : System.Web.UI.Page
{
SqlConnection con; SqlDataAdapter da; DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
    con = new SqlConnection(
         @"server=msmsm;database=pop;user id=sa;password=abc");
    con.Open();
    if (!IsPostBack)
    {
        getCountry();
    }
}
public void getCountry()
{
    string sqr="select * from country";
    da=new SqlDataAdapter (sqr,con);
    ds = new DataSet();
    da.Fill(ds,"country");
    Mydatalist.DataSource = ds.Tables[0];
    Mydatalist.DataBind();
}
protected void Mydatalist_ItemCommand(object source, DataListCommandEventArgs e)
{
    Panel pn = (Panel)e.Item.FindControl("mypane");
    pn.Visible = false;
    if (e.CommandName == "reply")
    {

        pn.Visible = true;
    }
}
}
</code></pre>
