I have a radgrid in batchedit. The Update and Select works fine but Insert didn't.
I use a defaultValue for a Select and Insert in code behind. For a select this works fine but when i try to insert the field of Database have null v
<
telerik:RadGrid
ID
=
"RGV"
runat
=
"server"
Width
=
"500px"
RenderMode
=
"Lightweight"
GridLines
=
"None"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
PageSize
=
"10"
AllowAutomaticUpdates
=
"True"
AllowPaging
=
"True"
AutoGenerateColumns
=
"False"
DataSourceID
=
"SDS"
Skin
=
"WebBlue"
>
<
MasterTableView
CommandItemDisplay
=
"TopAndBottom"
DataKeyNames
=
"id"
DataSourceID
=
"SDS"
HorizontalAlign
=
"NotSet"
EditMode
=
"Batch"
AutoGenerateColumns
=
"False"
CommandItemSettings-AddNewRecordText
=
"Insertar centro"
CommandItemSettings-SaveChangesText
=
"Guardar"
CommandItemSettings-CancelChangesText
=
"Cancelar"
CommandItemSettings-RefreshText
=
"Refrescar"
NoMasterRecordsText
=
"No data"
NoDetailRecordsText
=
"No data"
>
<
BatchEditingSettings
EditType
=
"Cell"
/>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Empresa"
HeaderText
=
"Empresa"
SortExpression
=
"Empresa"
UniqueName
=
"Empresa"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Numero"
HeaderText
=
"Numero"
SortExpression
=
"Numero"
UniqueName
=
"Numero"
>
</
telerik:GridBoundColumn
>
<
telerik:GridDateTimeColumn
DataField
=
"Desde"
HeaderText
=
"Desde"
SortExpression
=
"Desde"
UniqueName
=
"Desde"
>
</
telerik:GridDateTimeColumn
>
<
telerik:GridDateTimeColumn
DataField
=
"HastaEl"
HeaderText
=
"Hasta el"
SortExpression
=
"HastaEl"
UniqueName
=
"HastaEl"
>
</
telerik:GridDateTimeColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
AllowKeyboardNavigation
=
"true"
></
ClientSettings
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SDS"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:PCMConnectionString %>"
SelectCommand="SELECT * From Table1 Where idRevisionCentros=@idRevisionCentros"
InsertCommand="INSERT INTO Table1 (idRevisionCentros,Empresa,Numero,Desde,HastaEl) VALUES (@idRevisionCentros,@Empresa,@Numero,@Desde,@HastaEl)"
UpdateCommand="UPDATE Table1 SET Empresa=@Empresa, Numero=@Numero,Desde=@Desde,HastaEl=@HastaEl WHERE id = @id">
<
SelectParameters
>
<
asp:parameter
Name
=
"idRevisionCentros"
type
=
"Int32"
/>
</
SelectParameters
>
<
InsertParameters
>
<
asp:parameter
Name
=
"idRevisionCentros"
type
=
"Int32"
/>
<
asp:Parameter
Name
=
"Empresa"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Numero"
Type
=
"Int32"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Desde"
Type
=
"DateTime"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"HastaEl"
Type
=
"DateTime"
></
asp:Parameter
>
</
InsertParameters
>
<
UpdateParameters
>
<
asp:Parameter
Name
=
"id"
Type
=
"Int32"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Empresa"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Numero"
Type
=
"Int32"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Desde"
Type
=
"DateTime"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"HastaEl"
Type
=
"DateTime"
></
asp:Parameter
>
</
UpdateParameters
>
</
asp:SqlDataSource
>
</
fieldset
>
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
int
idRevisionCentros = getIdRevisionCentros();
//return any number, for exemple 1;
SDS.SelectParameters[0].DefaultValue = idRevisionCentros.ToString();
//<-- Works fine
SDS.InsertParameters[0].DefaultValue = idRevisionCentros.ToString();
//<-- Insert null in DB for this field.....
}
}