开发者

gridview select button to be a link to a page

开发者 https://www.devze.com 2023-02-11 06:38 出处:网络
I want to have a gridview where the first field is a link to a page like mypage.aspx?selectedName=John if john row is selected or mypage.aspx?selectedName=Jim if Jim row is selected. How can I create

I want to have a gridview where the first field is a link to a page like mypage.aspx?selectedName=John if john row is selected or mypage.aspx?selectedName=Jim if Jim row is selected. How can I create the link for each开发者_运维百科 row?


Use a TemplateField to custom style a column.

<Columns>
  ... your other columns ...
  <asp:TemplateField HeaderText="Link">
    <ItemTemplate>
      <a href='<%# "mypage.aspx?selectedName=" + Eval("Name") %>'>Click me</a>
    </ItemTemplate>
  </asp:TemplateField>
</Columns>

Where Name is the name of the field that contains the name of the person.

0

精彩评论

暂无评论...
验证码 换一张
取 消