This is a migrated thread and some comments may be shown as answers.

[Solved] GridButtonColumn problem with LinkButtons

1 Answer 154 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 2
Sean asked on 29 Oct 2009, 02:41 PM
I'm trying to create a link column that displays text from the db.  It's currently a GridBoundColumn and it displays the text in the Status db field fine, but I want it to be a link so I tried this:
gridColumn = new GridButtonColumn();  
(gridColumn as GridButtonColumn).ButtonType = GridButtonColumnType.LinkButton;  
(gridColumn as GridButtonColumn).DataTextField = "Status";  
(gridColumn as GridButtonColumn).DataTextFormatString = "{0}";  
 
But the column shows this now 'System.Data.DataRowView' on every line instead of something like 'Accepted'.
What am I missing from setting up a Link column?
Status is defined as nvarchar(50) in the db.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Nov 2009, 10:40 AM
Hi

I have tried  a similar scenario and found it to be working .

 protected void Page_Load(object sender, EventArgs e)  
    {  
        if (!IsPostBack)  
        {  
            GridButtonColumn gridColumn;  
            //Important: first Add column to the collection  
            gridColumn = new GridButtonColumn();  
            this.RadGrid1.MasterTableView.Columns.Add(gridColumn);  
 
            //Then set properties  
            (gridColumn as GridButtonColumn).ButtonType = GridButtonColumnType.LinkButton;  
            (gridColumn as GridButtonColumn).DataTextField = "LastName";  
            (gridColumn as GridButtonColumn).DataTextFormatString = "{0}";  
            
        }  
 
    } 

The possible reason for the error is that the DataField Value may be incorrect. Could you recheck your code to make sure that this does not happen.

Thanks,
Princy
Tags
Grid
Asked by
Sean
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Share this question
or