public partial class Form1 : Form |
{ |
private readonly DataTable dtMain; |
public Form1() |
{ |
InitializeComponent(); |
dtMain = new DataTable(); |
CreateSampleTable(); |
InsertValues(); |
radGridView1.DataSource = dtMain; |
} |
private void CreateSampleTable() |
{ |
dtMain.Columns.Add(new DataColumn("column1", typeof(String))); |
dtMain.Columns.Add(new DataColumn("column2", typeof(String))); |
dtMain.Columns.Add(new DataColumn("column3", typeof(String))); |
} |
private void InsertValues () |
{ |
var drMain = dtMain.NewRow(); |
drMain["column1"] = "1"; |
drMain["column2"] = "One"; |
dtMain.Rows.Add(drMain); |
drMain = dtMain.NewRow(); |
drMain["column1"] = "2"; |
drMain["column2"] = "Two"; |
dtMain.Rows.Add(drMain); |
drMain = dtMain.NewRow(); |
drMain["column1"] = "3"; |
drMain["column2"] = "Three"; |
dtMain.Rows.Add(drMain); |
} |
private void radGridView1_RowFormatting(object sender, Telerik.WinControls.UI.RowFormattingEventArgs e) |
{ |
var gvri = e.RowElement.RowInfo; |
var rbApply = gvri.Cells["column3"] != null && gvri.Cells["column3"].CellElement != null ? |
gvri.Cells["column3"].CellElement.Children[0] as RadButtonElement : null; |
if (rbApply != null) |
{ |
rbApply.Text = "Apply"; |
rbApply.TextAlignment = ContentAlignment.MiddleCenter; |
} |
} |
} |
I have a rad gridview windows control with two text columns and a button column. AllowAddNewRow is set to "True" for the Gridview. I have set the Text property of the button to "Apply" in RowFormatting event.There are three rows in the datasource.When the application is run, we can see the button text assigned for those three rows. But the RowFormatting event is not fired when the new row is selected, So the newly created row will have a button with blank text. Please help me on this.
Regards
Shamjith