Get text of ASP.NET HyperLinkField in GridView

前端 未结 3 591
北恋
北恋 2020-12-20 20:06

I\'m trying to get the text of a HyperLinkField in a GridView\'s OnRowDelete event (the HyperLinkField\'s text is the primary key of the row I wish to delete). I understand

相关标签:
3条回答
  • 2020-12-20 20:30

    Another alternative method of getting the text value of a hyperlink:

    Server.HtmlDecode((teamGridView.Rows[e.RowIndex].Cells[0].Controls[0] as HyperLink).Text)
    
    0 讨论(0)
  • 2020-12-20 20:31

    Instead of

    teamGridView.Rows[e.RowIndex].Cells[0].Text;
    

    Try

    ( (HyperLink) teamGridView.Rows[e.RowIndex].Cells[0].Controls[0] ).Text
    

    Just can't avoid advising you to change the way you put all SQL directly in your page like this. Try leaning about N tier development. MSDN and asp.NET website and channel9.msdn have good videos to start with. Also, http://weblogs.asp.net/scottgu

    http://gurustop.net

    0 讨论(0)
  • 2020-12-20 20:47
    ((HyperLink)teamGridView.Rows[e.RowIndex].Cells[0].Controls[0] ).Text 
    

    will give the text or displayed value of the field. Alternatively we can try

    ((HyperLink)teamGridView.Rows[e.RowIndex].Cells[0].Controls[0] ).NavigateUrl
    

    for getting the target link.

    0 讨论(0)
提交回复
热议问题