Andrea Gorin
Top achievements
Rank 2
Andrea Gorin
asked on 18 Dec 2009, 03:25 PM
I'm a newbie og RadGrid.
Default mode of RadGrid in edit mode don't permit insertion of key values.
There is a mode, only for new record (ADD NEW RECORD), to insert key value ?
Thanks, Andrea
Default mode of RadGrid in edit mode don't permit insertion of key values.
There is a mode, only for new record (ADD NEW RECORD), to insert key value ?
Thanks, Andrea
6 Answers, 1 is accepted
0
Hello Andrea,
Try the following code:
Regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Try the following code:
protected
void
RadGrid1_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item.IsInEditMode && !(e.Item
is
IGridInsertItem))
{
((e.Item
as
GridEditableItem)[
"Col1"
].Controls[0]
as
WebControl).Enabled =
false
;
}
}
Regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Andrea Gorin
Top achievements
Rank 2
answered on 18 Dec 2009, 04:33 PM
The expression: (e.Item.IsInEditMode && !(e.Item is IGridInsertItem)) return always false.
e.Item.IsInEditMode always return false
and
!(e.Item is IGridInsertItem) retrun true
In insert mode radgrid seems to analyze all records... :-o
RadGrid in aspx file:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" DataSourceID="ldsParametri"
GridLines="None" AllowSorting="True" AutoGenerateColumns="False" AllowAutomaticDeletes="True"
AllowAutomaticInserts="True" AllowAutomaticUpdates="True" ShowStatusBar="True"
Width="100%" onitemcreated="RadGrid1_ItemCreated">
<PagerStyle Mode="NumericPages" AlwaysVisible="true" />
<MasterTableView CommandItemDisplay="Top" DataKeyNames="ID_Azienda,Nome" DataSourceID="ldsParametri"
GridLines="None" Width="100%">
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" />
<telerik:GridBoundColumn DataField="ID_Azienda" HeaderText="ID_Azienda" SortExpression="ID_Azienda"
UniqueName="ID_Azienda" ReadOnly="True" Visible="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Nome" HeaderText="Nome" SortExpression="Nome"
UniqueName="Nome" ReadOnly="True">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Valore" HeaderText="Valore" SortExpression="Valore"
UniqueName="Valore">
</telerik:GridBoundColumn>
<telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ConfirmDialogType="Classic"
ConfirmText="Vuoi eliminare questa riga ?" ConfirmTitle="Elimina" UniqueName="Elimina" />
</Columns>
</MasterTableView>
</telerik:RadGrid>
e.Item.IsInEditMode always return false
and
!(e.Item is IGridInsertItem) retrun true
In insert mode radgrid seems to analyze all records... :-o
RadGrid in aspx file:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" DataSourceID="ldsParametri"
GridLines="None" AllowSorting="True" AutoGenerateColumns="False" AllowAutomaticDeletes="True"
AllowAutomaticInserts="True" AllowAutomaticUpdates="True" ShowStatusBar="True"
Width="100%" onitemcreated="RadGrid1_ItemCreated">
<PagerStyle Mode="NumericPages" AlwaysVisible="true" />
<MasterTableView CommandItemDisplay="Top" DataKeyNames="ID_Azienda,Nome" DataSourceID="ldsParametri"
GridLines="None" Width="100%">
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" />
<telerik:GridBoundColumn DataField="ID_Azienda" HeaderText="ID_Azienda" SortExpression="ID_Azienda"
UniqueName="ID_Azienda" ReadOnly="True" Visible="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Nome" HeaderText="Nome" SortExpression="Nome"
UniqueName="Nome" ReadOnly="True">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Valore" HeaderText="Valore" SortExpression="Valore"
UniqueName="Valore">
</telerik:GridBoundColumn>
<telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ConfirmDialogType="Classic"
ConfirmText="Vuoi eliminare questa riga ?" ConfirmTitle="Elimina" UniqueName="Elimina" />
</Columns>
</MasterTableView>
</telerik:RadGrid>
0
Hello Andrea,
For your convenience I created a simplified demo project based on your code-snippet. Please test it locally and let me know whether it works as expected.
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
For your convenience I created a simplified demo project based on your code-snippet. Please test it locally and let me know whether it works as expected.
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Andrea Gorin
Top achievements
Rank 2
answered on 19 Dec 2009, 05:43 PM
Hi Daniel,
Thanks, your code work ok!
In my project I have changed column to disable ("Nome" instead of "Valore", one of key fields).
There is a mode to set a defalut value another key field (ID_Azienda) ?
Thanks Andrea.
Thanks, your code work ok!
In my project I have changed column to disable ("Nome" instead of "Valore", one of key fields).
There is a mode to set a defalut value another key field (ID_Azienda) ?
Thanks Andrea.
0
Hello Andrea,
You can set a default value as explained in the following topics:
Insert mode:
Inserting values in-place and EditForms
Edit mode:
Updating values in-place and with edit forms
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
You can set a default value as explained in the following topics:
Insert mode:
Inserting values in-place and EditForms
Edit mode:
Updating values in-place and with edit forms
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Andrea Gorin
Top achievements
Rank 2
answered on 30 Dec 2009, 01:27 PM
Ok, thank you Daniel