<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”
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e) { var link = e.Row.FindControl("xxx") as HyperLink; if (link != null) { link.NavigateUrl = "www.baidu.com"; } }