首页新闻找找看学习计划

嵌套的GridView,子层GridView中HyperLink如何绑定链接地址?

0
悬赏园豆:10 [已解决问题] 解决于 2012-07-09 08:28
View Code
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" HeaderStyle-HorizontalAlign="Center"
                        HeaderStyle-VerticalAlign="Middle" RowStyle-Height="15px" RowStyle-HorizontalAlign="Center"
                        RowStyle-VerticalAlign="Middle" Width="700px"  
                        onrowediting="GridView1_RowEditing" 
                        onprerender="GridView1_PreRender"  >
                        <Columns>
                            <asp:BoundField HeaderText="单号" DataField="TaskId" >
                                <ItemStyle Width="90px" HorizontalAlign="left"/>
                            </asp:BoundField>
                            <asp:BoundField HeaderText="责任人" DataField="DesignerName" >
                                <ItemStyle Width="70px" HorizontalAlign="left"/>
                            </asp:BoundField>
                            <asp:BoundField HeaderText="要求完成日期" DataField="TechDate" >
                                <ItemStyle Width="90px" HorizontalAlign="left"/>
                            </asp:BoundField>
                            <asp:BoundField HeaderText="要求" DataField="DesignDesc" >
                                <ItemStyle Width="70px" HorizontalAlign="left"/>
                            </asp:BoundField>
                            <asp:CommandField  ShowEditButton="True" HeaderText="新增" 
                                EditText="新增" />                                                          
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false" 
                                        onrowdatabound="GridView2_RowDataBound" 
                                        onrowdeleting="GridView2_RowDeleting"                                         >
                                    <Columns>
                                    <asp:TemplateField>
                                    <ItemTemplate>
                                     <asp:Label ID="SDTest" Text ='<%#Eval("TaskId") %>' runat="server" Visible="false" ></asp:Label>
                                    </ItemTemplate>
                                    </asp:TemplateField>
                                   
                                    <asp:BoundField HeaderText="单号"  DataField="TmId" >
                                        <ItemStyle Width="90px" HorizontalAlign="left"/>
                                    </asp:BoundField>  
                                    <asp:TemplateField>
                                    <ItemTemplate>
                                    <asp:HyperLink ID="xxx" runat="server"  NavigateUrl=""></asp:HyperLink>
                                    </ItemTemplate>
                                    </asp:TemplateField>                                  
                                                                 
                                    <asp:BoundField HeaderText="状态" DataField="TmStatus" >
                                        <ItemStyle Width="90px" HorizontalAlign="left"/>
                                    </asp:BoundField>
                                      <asp:TemplateField HeaderText="">
                                     <ItemTemplate>
                                        <asp:LinkButton ID="linkDeleteCust" CommandName="Delete" runat="server">删除</asp:LinkButton>
                                     </ItemTemplate>                             
                                     </asp:TemplateField>
                                    </Columns>
                                    </asp:GridView>                              
                                </ItemTemplate>
                            </asp:TemplateField>                           
                        </Columns>
                        <RowStyle Height="15px" HorizontalAlign="Center" VerticalAlign="Middle" />
                        <HeaderStyle BackColor="#9CCFFF" HorizontalAlign="Center" VerticalAlign="Middle" />
                    </asp:GridView>

 

 

嵌套的GridView,子层GridView中HyperLink如何绑定链接地址?

 实例中是预设为空的,数据绑定的时候,如何设置链接地址类似如“www.baidu.com”

Alphay的主页 Alphay | 初学一级 | 园豆:190
提问于:2012-07-06 15:01
< >
分享
最佳答案
0
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            var link = e.Row.FindControl("xxx") as HyperLink;
            if (link != null)
            {
                link.NavigateUrl = "www.baidu.com";
            }
        }
收获园豆:10
安卓粉丝 | 初学一级 |园豆:99 | 2012-07-08 12:49
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册