DataGrid1_SelectedIndexChanged(sender As Object, e As EventArgs)

解决方案 »

  1.   

    使用模板列,然后实现模板列控件的clicked事件!
      

  2.   

    这有个example, 你看看,private void MyGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if (e.Item.ItemIndex >= 0)
    {
    e.Item.Attributes["OnClick"] = "window.open('ModShop.aspx?shop_id=" + DataGrid1.DataKeys[(int)e.Item.ItemIndex] + "')";

    }
      

  3.   

    这有个example, 你看看,private void MyGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if (e.Item.ItemIndex >= 0)
    {
    e.Item.Attributes["OnClick"] = "window.open('ModShop.aspx?shop_id=" + DataGrid1.DataKeys[(int)e.Item.ItemIndex] + "')";
    }
      

  4.   

    很笨的一种办法,让button控件的背景色改为透明,不用名称,然后在javascript里调用click事件,具体实现如下:
    private void MyGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if (e.Item.ItemIndex>-1)
    {
    e.Item.Attributes.Add("onmouseover","this.setAttribute('BKC',this.style.backgroundColor); this.style.cursor='hand';this.style.backgroundColor='#dddddd'");
    e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=this.getAttribute('BKC');");
    e.Item.Attributes.Add("onclick","javascript:GridClick();");
    }
    }
    在javascript中
    function GridClick()
    {
    document.Form1.Button1.click();
    }
    想在后台执行什么操作就写在button1的click事件里就行了