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

button column

1 Answer 168 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mateo
Top achievements
Rank 1
Mateo asked on 05 Sep 2007, 05:43 PM
Couple of questions that i don't seem to find in the doc.

1- I need to show a global button in the top of the datagrid to add a new row for example. How can i do this and trigger the new row event?

2- I need to show a delete and update button for each row in the grid when edit mode is allowed.

3- How can i get the object binded to a row in a datagrid (the this property).

Thanks
mateo

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 06 Sep 2007, 09:52 AM
Hi Mateo,

  1. On your first question: The easiest solution is to put some button at the desired position on your form. You can also add a RadButtonElement to grid HeaderElement's children collection:

     RadButtonElement button = new RadButtonElement();
     button.Text = "Add new row";
     button.Click += new EventHandler(button_Click);
     ((GridTableElement)this.radGridView1.GridElement).HeaderElement.Children.Add(button);


    In your button_Click event change the current row position:

    this.radGridView1.MasterGridViewInfo.TableAddNewRow.IsCurrent = true;

    As an alternative you can add new row by code:

    this.radGridView1.Rows.Add("John", "Smith", "555-232-435");

  2. Regarding the second question: This is not possible with the current version of RadGridView. We will add API for adding custom buttons in grid rows in one of our next versions
  3. To get the bound object to a row use the DataBoundItem property of GridViewRowInfo:

    object boundObject = this.radGridView1.Rows[3].DataBoundItem;

Greetings,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Mateo
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or