back_01.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="back_01.aspx.cs" Inherits="admin_addip" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2" borderColor="Black" BorderWidth="1px"  HorizontalAlign="Center" Font-Size="X-Small" ForeColor="Transparent" DataKeyNames="pipe_num" OnRowDataBound="GridView1_RowDataBound1">
            <Columns>
               <asp:HyperLinkField HeaderText="pipe_num" DataTextField="pipe_num" DataNavigateUrlFields="pipe_num" DataNavigateUrlFormatString="http://query.pipewest.cdwater.com.cn/Cad_Picture/Cad_View.asp?pipe_num={0}"> </asp:HyperLinkField> 
                <asp:BoundField DataField="id" HeaderText="id" SortExpression="id" />
             </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:newcxgwConnectionString2 %>"
            SelectCommand="SELECT top 10 * FROM dbo.back_pro">
        </asp:SqlDataSource>
    </form>
</body>
</html>back_01.aspx.cs///我要得到选中行id得数值,然后传给2.asp
protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex != -1)
        {
            e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#bfd4e6'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#efefef'");
            string id = GridView1.Rows[e.Row.RowIndex].Cells[e.列名].ToString();////有错,还是前面页面就有错
            e.Row.Attributes.Add("ondblclick", "window.open('2.asp?id=" + id + "')");
        }     }

解决方案 »

  1.   

    string id = GridView1.Rows[e.Row.RowIndex].Cells[e.列名].ToString();////有错,还是前面页面就有错 
    --------
    string id = GridView1.Rows[e.Row.RowIndex].Cells[e.列名].value.ToString();////有错,还是前面页面就有错 
      

  2.   

    我要把id传过来 ,始终有错,帮忙改哈
    string id = GridView1.Rows[e.Row.RowIndex].Cells[1].value.ToString();////有错,还是前面页面就有错
      

  3.   

    e.Row.Attributes.Add("ondblclick", "window.open('2.asp?id=" + id + "')"); 
    应该是2.aspx吧
      

  4.   

    各位高手 在线等待 改成这个也有错string id = GridView1.Rows[e.Row.RowIndex].Cells[1].Text;to  :zzyhuian06142
    这个没的错
    e.Row.Attributes.Add("ondblclick", "window.open('2.asp?id=" + id + "')"); 
     
      

  5.   

    现在我开始怀疑第一个页面是不是缺撒子?????
    <asp:BoundField DataField="id" HeaderText="id" SortExpression="id" />