On adding new row in RadGridView, I am assigning DefaultValues in DefaultValuesNeeded event. When I start typing in the new row, the default values appear but the moment I hit enter on the row ( so that it is added to the current grid ) , all the default values just disappear.
I have created columns dynamically.
Please tell me what is the issue or am I missing anything ?
Below is my code.
grid code:
I have created columns dynamically.
Please tell me what is the issue or am I missing anything ?
Below is my code.
grid code:
private
void
BindGrid()
{
this
.ExportSettingGridView.AllowAddNewRow =
false
;
this
.ExportSettingGridView.AutoGenerateColumns =
false
;
this
.ExportSettingGridView.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this
.ExportSettingGridView.ShowGroupPanel =
false
;
this
.ExportSettingGridView.MasterTemplate.EnableGrouping =
false
;
this
.ExportSettingGridView.EnableHotTracking =
true
;
//Settings Name column
GridViewTextBoxColumn nameCol =
new
GridViewTextBoxColumn();
nameCol.FieldName =
"Name"
;
nameCol.Name =
"Name"
;
nameCol.HeaderText =
"Export Setting"
;
this
.ExportSettingGridView.Columns.Add(nameCol);
//Settings Na Option Combo Box
GridViewComboBoxColumn naDataOptionCol =
new
GridViewComboBoxColumn();
naDataOptionCol.FieldName =
"NaData.NaDataOption"
;
naDataOptionCol.Name =
"NaData.NaDataOption"
;
naDataOptionCol.HeaderText =
"NA Data Option"
;
naDataOptionCol.DataSource = Enum.GetValues(
typeof
(NADataOption));
naDataOptionCol.DataType =
typeof
(NADataOption);
naDataOptionCol.DataSourceNullValue = NADataOption.BLANKROW;
this
.ExportSettingGridView.Columns.Add(naDataOptionCol);
//Setting NA Option Custom Text field Columns
GridViewTextBoxColumn naDataOptionCustomCol =
new
GridViewTextBoxColumn();
naDataOptionCustomCol.FieldName =
"NaData.Custom"
;
naDataOptionCustomCol.Name =
"NaData.Custom"
;
naDataOptionCustomCol.HeaderText =
"NA Data Option Custom"
;
this
.ExportSettingGridView.Columns.Add(naDataOptionCustomCol);
//Setting IncludePartialLastPeriod
GridViewComboBoxColumn includePartialLastPeriodCol =
new
GridViewComboBoxColumn();
includePartialLastPeriodCol.FieldName =
"IncludePartialLastPeriod"
;
includePartialLastPeriodCol.HeaderText =
"Include Partial Last Period"
;
includePartialLastPeriodCol.Name =
"IncludePartialLastPeriod"
;
includePartialLastPeriodCol.DataSource =
new
String[] {
"True"
,
"False"
};
includePartialLastPeriodCol.DataType =
typeof
(
bool
);
this
.ExportSettingGridView.Columns.Add(includePartialLastPeriodCol);
//Setting Sorting Column
GridViewComboBoxColumn sortingCol =
new
GridViewComboBoxColumn();
sortingCol.FieldName =
"Sorting"
;
sortingCol.HeaderText =
"Sorting"
;
sortingCol.Name =
"Sorting"
;
sortingCol.DataSource =
new
String[] {
"ASC"
,
"DESC"
};
this
.ExportSettingGridView.Columns.Add(sortingCol);
//Setting Data Load Position
GridViewComboBoxColumn dataPostionOptionsCol =
new
GridViewComboBoxColumn();
dataPostionOptionsCol.FieldName =
"DataLoadPosition.CursorLocation"
;
dataPostionOptionsCol.Name =
"DataLoadPosition.CursorLocation"
;
dataPostionOptionsCol.HeaderText =
"Cursor Location"
;
dataPostionOptionsCol.DataSource =
new
String[] {
"True"
,
"False"
};
dataPostionOptionsCol.DataType =
typeof
(
bool
);
dataPostionOptionsCol.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
this
.ExportSettingGridView.Columns.Add(dataPostionOptionsCol);
//Setting Data Load Cell location
GridViewTextBoxColumn cellCol =
new
GridViewTextBoxColumn();
cellCol.FieldName =
"DataLoadPosition.Cell"
;
cellCol.Name =
"DataLoadPosition.Cell"
;
cellCol.HeaderText =
"Cell Location"
;
this
.ExportSettingGridView.Columns.Add(cellCol);
this
.ExportSettingGridView.BestFitColumns();
}
private void newButton_Click(object sender, EventArgs e)
{
this.ExportSettingGridView.AllowAddNewRow = !this.ExportSettingGridView.AllowAddNewRow;
}
private void ExportSettingGridView_DefaultValuesNeeded(object sender, GridViewRowEventArgs e)
{
if (e.Row != null && e.Row is GridViewNewRowInfo)
{
e.Row.Cells["NaData.NaDataOption"].Value = currentProfile.NaData.NaDataOption;
e.Row.Cells["NaData.Custom"].Value = currentProfile.NaData.Custom;
e.Row.Cells["DataLoadPosition.CursorLocation"].Value = currentProfile.DataLoadPosition.CursorLocation;
e.Row.Cells["DataLoadPosition.Cell"].Value = currentProfile.DataLoadPosition.Cell;
}
}