天天看點

怎麼觸發gridview 的SelectedIndexChanged事件? - asdyzh

怎麼觸發gridview 的SelectedIndexChanged事件?

<asp:GridView onclick="javascript:SelectedIndexChanged()" ID="GridView1" runat="server">

        </asp:GridView>

<script type="text/javascript">

function SelectedIndexChanged()

{

     event.cancelBubble=true;

     var the_obj = event.srcElement;

     if(the_obj.tagName.toLowerCase() != "table" && the_obj.tagName.toLowerCase() != "tbody" && the_obj.tagName.toLowerCase() != "tr")

     {

         cur_row = the_obj.parentElement.rowIndex;

if(cur_row!=0)

{

     __doPostBack("GridView1",cur_row);

}

      }

}

</script>