6 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 06 Feb 2009, 04:45 AM
Hi John,
I am not sure what exactly is your requirement. For preventing editing of a particular GridColumn you can set the Column's ReadOnly property to true.
You can try the following code snippet to prevent editing of entire Grid rows.
Shinu
I am not sure what exactly is your requirement. For preventing editing of a particular GridColumn you can set the Column's ReadOnly property to true.
You can try the following code snippet to prevent editing of entire Grid rows.
| protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
| { |
| if (e.CommandName == "Edit") |
| { |
| e.Canceled = true; |
| } |
| } |
Shinu
0
john
Top achievements
Rank 1
answered on 06 Feb 2009, 07:24 AM
Hi shinu,
Thanks for your reply.Actually I want to get the contents of the row every time edit button is clicked and display it in the server controls that were used to insert the information.The user will then edit the row data there.My employer wants it to work that way.So is there a way for me to access the contents of a row that has its edit button clicked?.
Thanks for your reply.Actually I want to get the contents of the row every time edit button is clicked and display it in the server controls that were used to insert the information.The user will then edit the row data there.My employer wants it to work that way.So is there a way for me to access the contents of a row that has its edit button clicked?.
0
Accepted
Hello John,
You can access the underlying GridDataItem using the following approach:
Best regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
You can access the underlying GridDataItem using the following approach:
| protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
| { |
| if(e.CommandName == "Edit") |
| { |
| Hashtable values = new Hashtable(); |
| (e.Item as GridDataItem).ExtractValues(values); |
| string yourValue = values["yourValue"].ToString(); |
| } |
| } |
Best regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Accepted
Princy
Top achievements
Rank 2
answered on 06 Feb 2009, 08:10 AM
Hi John,
If you do not want to edit the row on clicking the button and just get the row data, you may consider using a GridButtonColumn with a CommandName set instead of GridEditCommandColumn. In the ItemCommand event you can check for the CommandName and access the row data.
ASPX:
CS:
Thanks
Princy.
If you do not want to edit the row on clicking the button and just get the row data, you may consider using a GridButtonColumn with a CommandName set instead of GridEditCommandColumn. In the ItemCommand event you can check for the CommandName and access the row data.
ASPX:
<telerik:GridButtonColumn ButtonType="linkbutton" Text="MyCommand" HeaderText="MyCommandCol" CommandName="MyCommand" ></telerik:GridButtonColumn> |
CS:
| protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
| { |
| if (e.CommandName == "MyCommand") |
| { |
| GridDataItem item = (GridDataItem)e.Item; |
| string strName = item["ProductName"].Text; |
| string strID = item["SupplierID"].Text; |
| } |
| } |
Thanks
Princy.
0
john
Top achievements
Rank 1
answered on 06 Feb 2009, 09:09 AM
thanks for the help guys, my problem has been solved.
0
Jack Jim
Top achievements
Rank 1
answered on 01 Dec 2009, 07:00 AM
Hi Shinu,
thanks a lot...your code worked for my requirement.
Thanks
thanks a lot...your code worked for my requirement.
Thanks