How to access a panel inside gridview from Javascript?
<p>I have a grid view, which contains a dropdownlist and a panel that i want to make invisible and visible by the selected value of the dropdownlist.</p>

<p>The javascript code which works when not used with the gridview is:</p>

<pre><code>   function showPannel(panelId,dropdownId ) {
        var panel = document.getElementById(panelId);
        var dropDown = document.getElementById(dropdownId);
        if (dropDown.options[dropDown.selectedIndex].value = 'Diesel Deals') {
             panel.className = "visibleDiv";

       }
        else{
            panel.className = "hiddenDiv";
            }

    }
</code></pre>

<p>i'm passing the panelId and dropdownlist id from here:</p>

<pre><code>    if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Panel p = (Panel)e.Row.FindControl("Panel1");
            DropDownList t1 = (DropDownList)e.Row.FindControl("DropDownList1");
            t1.Attributes.Add("onchange",
                 string.Format("javascript:showPannel('{0}', '{1}')",p.ClientID, t1.ClientID ));
        }
</code></pre>

<p>but it is not working. The function is getting called, but its giving undefined when dropDown.options[dropDown.selectedIndex].value  is alerted.</p>

<p>I tried to do </p>

<pre><code>                    Gridview1 = document.getElementById('&lt;%=GridView1.ClientID%&gt;');
             var cell = Gridview1.rows[0].cells[2];
             var dropdownlist = cell.childNodes[0];
             var dropdownSelectedValue = dropdownlist.options[dropdownlist.selectedIndex].value;
             alert(dropdownSelectedValue); 
</code></pre>

<p>but its not working either.</p>

<p>Please help</p>

<p>Thanks</p>
