Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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();
Posted
Comments
vulisiramu 15-Jul-13 4:07am    
we are using Devexpress ASPxGridView control in this RowDataBound event is not there.
Member 9591429 29-Aug-18 2:34am    
the same is for me also..want to bind dynamic column to ASPXlink button in devexpress gridview

1 solution

Try this

C#
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);
        }
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900