0

I'm Trying to Bind a Hyperlink Control " server side " to another Column's Value when Selected Index changed

<asp:HyperLink ID="HyperLinkID" runat="server"  NavigateUrl='<%# "WebPage.aspx?" & DataGridName.Items[DataGridName.SelectedIndex].Cells[8].Text]  %>'
                                     Visible="false">HyperLink Text</asp:HyperLink>

DataGridName.Items[DataGridName.SelectedIndex].Cells[8].Text] 使用while binding有问题吗?我只是想获取所选索引以获取其对应的另一列的值

4

1 回答 1

0

您尝试使用ItemCommand event您的 DataGrid。

在后面的代码中ItemCommand

void ItemsGrid_Command(Object sender, DataGridCommandEventArgs e)
{
 HyperLinkID.NavigateUrl = "WebPage.aspx" &  e.Item.Cells[8].Text
}

Aspx 代码

 <asp:DataGrid id="ItemsGrid"  ...
                    OnItemCommand="ItemsGrid_Command">
 <Columns>
            <asp:ButtonColumn 
                 HeaderText="Select item" 
                 ButtonType="LinkButton" 
                 Text="Select" 
                 CommandName="Select"/>  

  </Columns>
  </asp:DataGrid
于 2012-09-29T12:16:21.623 回答