3 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 10 Feb 2014, 05:21 AM
Hi Xiang,
You can use a GridButtonColumn and set its CommandName as Edit and if you want to edit that field you can have it in a BoundColumn with display as false. Please try the below code snippet:
ASPX:
Thanks,
Princy
You can use a GridButtonColumn and set its CommandName as Edit and if you want to edit that field you can have it in a BoundColumn with display as false. Please try the below code snippet:
ASPX:
<
telerik:GridButtonColumn
DataTextField
=
"Name"
CommandName
=
"Edit"
ButtonType
=
"LinkButton"
>
</
telerik:GridButtonColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"Name"
DataField
=
"Name"
HeaderText
=
"Name"
Display
=
"false"
>
</
telerik:GridBoundColumn
>
Thanks,
Princy
0

xiang
Top achievements
Rank 1
answered on 13 Feb 2014, 09:28 PM
I don't want to use the GridButtonColumn either. I want to have the column data bound to the name field and displayed like a link. Click the name will bring up the Edit form or pop-up window.
Thanks,
Thanks,
0

Princy
Top achievements
Rank 2
answered on 14 Feb 2014, 08:14 AM
Hi xiang,
Please try the following code snippet:
ASPX:
C#:
Thanks,
Princy
Please try the following code snippet:
ASPX:
<
telerik:GridBoundColumn
DataField
=
"ShipCity"
HeaderText
=
"ShipCity"
UniqueName
=
"ShipCity"
/>
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
foreach
(GridColumn col
in
RadGrid1.MasterTableView.Columns)
{
if
(col.UniqueName ==
"ShipCity"
)
{
LinkButton lnk =
new
LinkButton();
lnk.ID =
"LinkButton"
+ col.UniqueName;
lnk.Text = item[col.UniqueName].Text;
lnk.CommandName =
"Edit"
;
item[col.UniqueName].Controls.Add(lnk);
}
}
}
}
protected
void
RadGrid1_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
foreach
(GridColumn col
in
RadGrid1.MasterTableView.Columns)
{
if
(col.UniqueName ==
"ShipCity"
)
{
LinkButton lnk =
new
LinkButton();
lnk.ID =
"LinkButton"
+ col.UniqueName;
lnk.Text = item[col.UniqueName].Text;
lnk.CommandName =
"Edit"
;
item[col.UniqueName].Controls.Add(lnk);
}
}
}
}
Thanks,
Princy