当前位置:编程学习 > C#/ASP.NET >>

c#中gridview点击每一行数据进行传送一列的值,然后跳转

求大神指点啊。。
gridview如下
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            CellPadding="4" GridLines="None" ForeColor="#333333" Width="100%" CssClass="tabListBorder nolrbd" >
        <FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
        <RowStyle BackColor="#EFF3FB" />
        <Columns>
            <asp:BoundField HeaderText="项目名称"  DataField="txtProject"/>
            <asp:BoundField HeaderText="发生日期"  DataField="datHospTime"/>
            <asp:BoundField HeaderText="费用总额"  DataField="numSum"/>
            <asp:BoundField HeaderText="实报总额"  DataField="numInFact"/>
            <asp:BoundField HeaderText="是否报销"  DataField="txtCStatus"/>
            <asp:BoundField HeaderText="未报原因"  DataField="txtReason"/>
        </Columns>
    
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Left" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    
                  <EditRowStyle BackColor="#2461BF" />
                  <AlternatingRowStyle BackColor="White" />
    
    </asp:GridView>  

数据都有显示,我想点击每一行的其中一列数据比如说"ID",进行新页面跳转,并传输当前ID的值,

我记得datalist可以做的
 <td width= "50%"><div align="left"><a target='_blank' href="http://www.xxxx.com/consult_update1.aspx?id=<%#Eval("id") %>"> <%# DataBinder.Eval(Container.DataItem,"Title") %></a></div></td>
然后通过session,可以传送值,隐藏几个lbl_text就行,
但是gridview如何做啊。。。 --------------------编程问答-------------------- 如果 e.Row.Cells[1].Text 是ID
 
GridView1_RowDataBound 事件里写

if (e.Row.RowIndex>0)
{
e.Row.Cells[1].Text = "<a href='http://www.xxxx.com/consult_update1.aspx?id=" + e.Row.Cells[1].Text + "'>
}
这样 Cell[1] 的文本ID就带上连接了.连接中有ID这个参数 --------------------编程问答-------------------- 自己测试一下.
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,