如何设置GridView的一列中的超链接是自动生成的自动生成、如何设置、超链接、GridView

2023-09-04 06:20:51 作者:心動

我想使gridview.columns [0]作为超级链接。我想围绕提到在不同的部位这么多的工作。我绑定列表<>电网。与我需要使作为超链接和在点击该链接,它应该被重定向到一个页与相应的项目的第一列。 哪个事件我需要使用和如何传递这个值从列表中。

任何帮助将提前helpful..Thanks

解决方案

 无效GridView1_RowDataBound(对象发件人,GridViewRowEventArgs E)
{
    如果(e.Row.RowType == DataControlRowType.DataRow)
    {
        变种firstCell = e.Row.Cells [0];
        firstCell.Controls.Clear();
        firstCell.Controls.Add(新的超链接{NavigateUrl = firstCell.Text,文本= firstCell.Text});
    }
}
 

被警告说,如果你将数据绑定到网格只加载第一次页面,然后更改就会消失。

I want to make the gridview.columns[0] as hyperlink. I tried so many work around mentioned in different sites. I am binding a list<> to the grid. and i need to make the first column as hyperlink and upon clicking that link, it should be redirected to a page with the corresponding item. Which event i need to use and how can i pass that value from the list.

想在word文档中的第一页自动生成一个目录,如何设置 超链接

Any help will be helpful..Thanks in advance

解决方案

void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        var firstCell = e.Row.Cells[0];
        firstCell.Controls.Clear();
        firstCell.Controls.Add(new HyperLink { NavigateUrl = firstCell.Text, Text = firstCell.Text });
    }
}

Be warned that if you bind data to grid only first time page loaded then your changes will disappear.