I want get the some column detail by clicking the command button.
Ex: If a had price 10 as default and when i click command button the price will be updated as 12.
How can do this by using programmatically.
Thanks in advance.
Note: VB Coding
6 Answers, 1 is accepted
This will do what I *think* you are asking for, just a sample but should point the way:
Private Sub Form1_Load( sender As Object, e As EventArgs) Handles MyBase.Load 'create a command column (button) Dim commandColumn As New GridViewCommandColumn() 'name it so we cah check for it later commandColumn.Name = "change" commandColumn.UseDefaultText = False commandColumn.HeaderText = "Command" 'add the button RadGridView1.MasterTemplate.Columns.Add(commandColumn) 'add a column to hold price info Dim priceColumn As New GridViewTextBoxColumn() priceColumn.Name = "price" priceColumn.HeaderText = "Price" RadGridView1.MasterTemplate.Columns.Add(priceColumn) 'Adds three rows of data to the grid radgridview1.rows.add("Add","10") radgridview1.rows.add("Add","13") radgridview1.rows.add("Add","15") End Subthen in the events of the grid box choose the CellClick event and put something like this:
Private Sub RadGridView1_CellClick( sender As Object, e As GridViewCellEventArgs) Handles RadGridView1.CellClick 'everytime a cell is clicked this will run, check to see if they clicked the column named change if e.Column.name = "change" 'if so then take the current row and replace the value with whatever is typed in the textbox1 RadGridView1.mastertemplate.currentrow.cells("price").value = textbox1.text End IfEnd Sub
Let me know if you need clarification.
Joe
Sorry...I formatted the code as c#...here is it formatted correctly:
Private Sub Form1_Load( sender As Object, e As EventArgs) Handles MyBase.Load 'create a command column (button) Dim commandColumn As New GridViewCommandColumn() 'name it so we cah check for it later commandColumn.Name = "change" commandColumn.UseDefaultText = False commandColumn.HeaderText = "Command" 'add the button RadGridView1.MasterTemplate.Columns.Add(commandColumn) 'add a column to hold price info Dim priceColumn As New GridViewTextBoxColumn() priceColumn.Name = "price" priceColumn.HeaderText = "Price" RadGridView1.MasterTemplate.Columns.Add(priceColumn) 'Adds three rows of data to the grid radgridview1.rows.add("Add","10") radgridview1.rows.add("Add","13") radgridview1.rows.add("Add","15") End SubPrivate Sub RadGridView1_CellClick( sender As Object, e As GridViewCellEventArgs) Handles RadGridView1.CellClick 'everytime a cell is clicked this will run, check to see if they clicked the column named change if e.Column.name = "change" 'if so then take the current row and replace the value with whatever is typed in the textbox1 RadGridView1.mastertemplate.currentrow.cells("price").value = textbox1.text End IfEnd Sub
Hello;
I don't think you can on here (like on Stackoverflow?) Also, I would have uploaded the project but this does not allow upload of anything except pictures.
Let me know if this works out for you.
Good luck and happy coding!
Joe
@Joe, thank you for sharing your solution with our community. Your Telerik points are updated accordingly.
@Kumaran, users are not allowed to modify their posts. More detailed information on using our forum you can find here: Important Information on Using the Telerik Forums
Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
See What's Next in App Development. Register for TelerikNEXT.
