gridview 点击 行页面跳转

 

前台代码:

          <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="100%" EmptyDataText=" 无" BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" CellPadding="4" OnRowDataBound="GridView1_RowDataBound">
              <Columns>
                  <asp:TemplateField HeaderText="姓名">
                      <ItemTemplate>
                          <asp:Label ID="Label1" runat="server" Text='<%# Eval("TrueName") %>'></asp:Label>
                          <asp:HiddenField ID="HiddenField1" runat="server" Value='<%# Eval("id") %>' />
                      </ItemTemplate>
                      <ItemStyle Width="50px" />
                  </asp:TemplateField>
                  <asp:BoundField HeaderText="性别" DataField="sex" />
                  <asp:BoundField HeaderText="学历" DataField="Quslification" />
                  <asp:BoundField HeaderText="工作年限" DataField="JobExperience" />
                  <asp:BoundField HeaderText="求职行业" DataField="Industry" />
                  <asp:BoundField DataField="Funtype" HeaderText="求职岗位" />
                  <asp:BoundField HeaderText="求职地区" DataField="JobPlace" />
                  <asp:BoundField HeaderText="目前居住地" DataField="ContactAddress" Visible="False" />
                  <asp:BoundField HeaderText="户口所在地" DataField="Birthplace" Visible="False" />
              </Columns>
              <HeaderStyle HorizontalAlign="Left" Width="20px" BackColor="Azure" Font-Bold="True" ForeColor="#FFFFCC" />
              <RowStyle Width="20px" BackColor="White" ForeColor="#330099" />
              <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
              <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
              <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
          </asp:GridView>

后台代码:

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#cdebed';"+
                                "this.style.cursor='hand';");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");

            HiddenField hf = (HiddenField)e.Row.Cells[0].FindControl("HiddenField1");
            e.Row.Attributes.Add("onclick", "javascript:window.open('Jobseeker.aspx?id=" + hf.Value + "')");
        }
    }
posted @ 2011-01-11 11:30  天北涯  阅读(2341)  评论(0编辑  收藏  举报