如何将超链接动态绑定到垂直的ASPxGridView列 [英] How to Bind hyperlink to perticular ASPxGridView column dynamically

查看:124
本文介绍了如何将超链接动态绑定到垂直的ASPxGridView列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在此,我将数据动态绑定到ASPxGridView和
我想显示指向垂直列的超链接,但在下面的
代码显示到所有列的超链接.如何避免这个问题
请解决这个问题..


DataTable dt = GetTable();
ASPxGridView grv =新的ASPxGridView();

grv.SettingsPager.PageSize = 20;
grv.SettingsBehavior.AllowFocusedRow = true;
grv.Border.BorderColor = Color.Black;
grv.Caption =";

字符串名称=";

for(int j = 0; j< dt.Columns.Count; j ++)
{


名称= dt.Columns [j] .ColumnName;

GridViewDataHyperLinkColumn colLink =新的GridViewDataHyperLinkColumn();
colLink.Caption =名称;
colLink.FieldName =名称;
colLink.PropertiesHyperLinkEdit.Text =名称;
colLink.PropertiesHyperLinkEdit.TextField =名称;

colLink.PropertiesHyperLinkEdit.NavigateUrlFormatString ="../UISite/SiteMonitor.aspx?id =";

colLink.Visible = true;
colLink.Width = 50;

grv.Columns.Add(colLink);

}

grv.DataSource = dt;
grv.DataBind();

Hi,

In this i have dynamically bind data to the ASPxGridView and
i want to display hyperlink to perticular column but in the below
code displays hyperlink to all columns. how to avoid this problem
please solve this problem..


DataTable dt = GetTable();
ASPxGridView grv = new ASPxGridView();

grv.SettingsPager.PageSize = 20;
grv.SettingsBehavior.AllowFocusedRow = true;
grv.Border.BorderColor = Color.Black;
grv.Caption = "";

string name = "";

for (int j = 0; j < dt.Columns.Count; j++)
{


name = dt.Columns[j].ColumnName;

GridViewDataHyperLinkColumn colLink = new GridViewDataHyperLinkColumn();
colLink.Caption = name;
colLink.FieldName = name;
colLink.PropertiesHyperLinkEdit.Text = name;
colLink.PropertiesHyperLinkEdit.TextField = name;

colLink.PropertiesHyperLinkEdit.NavigateUrlFormatString = ".. / UISite / SiteMonitor.aspx? id =";

colLink.Visible = true;
colLink.Width = 50;

grv.Columns.Add(colLink);

}

grv.DataSource = dt;
grv.DataBind();

推荐答案

尝试一下

Try this

protected void grdData_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            HyperLink link = new HyperLink();
            link.Text = "This is a link!";
            link.NavigateUrl = "Navigate somewhere based on data: " + e.Row.DataItem;
            e.Row.Cells[ColumnIndex.Column1].Controls.Add(link);
        }
    }


这篇关于如何将超链接动态绑定到垂直的ASPxGridView列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆