就是我在使用
<asp:DataGrid>
    <asp:TemplateColumn HeaderText="业务分配">
       <ItemTemplate>
           <asp:ImageButton ID="modifyGIF" runat="server" ImageUrl="../css/images/modify.gif"
                                                                CommandName="modifyGIF" />
   <%-- <img src="../css/images/modify.gif" style="cursor: hand" onclick="window.open('ywxx_fp.aspx?Entp_ID=<%# DataBinder.Eval(Container.DataItem,"Entp_ID")%>', 'win19','width=700,height=570 ,top=200,left=120');">--%>
       </ItemTemplate>
    </asp:TemplateColumn>
</asp:DataGrid>在.aspx文件里:<img src="../css/images/modify.gif" style="cursor: hand" onclick="window.open('ywxx_fp.aspx?Entp_ID=<%# DataBinder.Eval(Container.DataItem,"Entp_ID")%>', 'win19','width=700,height=570 ,top=200,left=120');">将其中的绑定数据列转换列...如下:Entp_ID=<%# DataBinder.Eval(Container.DataItem,"Entp_ID")%>在.cs文件里该如何去转换啊!(也就是该如何去写)protected void DataGrid1_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                 ((ImageButton)e.Item.Cells[0].FindControl("modifyGIF")).Attributes.Add("onclick", "window.open                           ('ywxx_fp.aspx?Entp_ID=<%#DataBinder.Eval(Container.DataItem,"Entp_ID"', 'win19','width=700,height=570 ,top=200,left=120');");                
                
            }
        }

解决方案 »

  1.   

    <img runat="server"> 在dataItem初始化时,找到这个ID, 再attributes.add();试一下
    附个人网站,http://www.jgking.cn 欢迎光临
      

  2.   

    很简单吗,首先在aspx页面加个DataKeyField<asp:datagrid id="DataGrid1" runat="server"  DataKeyField="Entp_ID" AutoGenerateColumns="False">cs:protected   void   DataGrid1_ItemCommand(object   source,   DataGridCommandEventArgs   e) 
       { 
    string Entp_ID=this.DataGrid1.DataKeys[i].ToString();
                            if   (e.Item.ItemType   ==   ListItemType.Item   ¦ ¦   e.Item.ItemType   ==   ListItemType.AlternatingItem) 
                            { 
                                      ((ImageButton)e.Item.Cells[0].FindControl("modifyGIF")).Attributes.Add("onclick",   "window.open                                                       ('ywxx_fp.aspx?Entp_ID= "+ Entp_ID +"',   'win19','width=700,height=570   ,top=200,left=120');");                                 
                                    
                            } 
                    }就ok了
      

  3.   

    谢谢你啊!我自己解决,你方法可以,但我的另一种方式解决啊!在DataGrid加了一个如下:代码:
    <asp:BoundColumn Visible="False" DataField="Entp_ID" ReadOnly="True"></asp:BoundColumn>
                                                        <asp:TemplateColumn>
                                                            <ItemTemplate>
                                                                <asp:TextBox ID="entp_ID" runat="Server" Text='<%# DataBinder.Eval(Container.DataItem,"Entp_ID")%>'
                                                                    Visible="false"></asp:TextBox></ItemTemplate>
                                                        </asp:TemplateColumn>
    然后,在代码这样写:string tempString = ((TextBox)e.Item.Cells[0].FindControl("entp_ID")).Text.ToString();