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

Radgrid Insert - ASAP

2 Answers 21 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eva
Top achievements
Rank 1
Eva asked on 15 Jul 2011, 11:13 PM
Here is my code

 

<telerik:RadGrid ID="RadGrid1" runat="server"

AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"

DataSourceID="GetProvider" GridLines="None" Skin="Windows7" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True">

<MasterTableView AutoGenerateColumns="False" DataSourceID="GetProvider" CommandItemDisplay="Top" DataKeyNames="SuspendedProviderId" >

<Columns>

<telerik:GridBoundColumn DataField="SocialSecurityAct" HeaderText="SocialSecurityAct"

SortExpression="SocialSecurityAct" UniqueName="SocialSecurityAct">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="42CFR" HeaderText="42CFR" SortExpression="42CFR"

UniqueName="42CFR">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="42USC" HeaderText="42USC" SortExpression="42USC"

UniqueName="42USC">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description"

UniqueName="Description">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="SuspendedProviderId" DataType="System.Int32" Visible="false"

HeaderText="SuspendedProviderId" ReadOnly="True" SortExpression="SuspendedProviderId"

UniqueName="SuspendedProviderId">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="Id" DataType="System.Int32" HeaderText="Id" Visible="false"

SortExpression="Id" UniqueName="Id">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="SuspendedProviderId" DataType="System.Int32" Visible="false"

HeaderText="SuspendedProviderId" SortExpression="SuspendedProviderId" UniqueName="SuspendedProviderId">

</telerik:GridBoundColumn>

</Columns>

<EditFormSettings EditFormType="Template">

<FormTemplate>

<table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"

style="border-collapse: collapse; background: white;">

<tr class="EditFormHeader">

<td colspan="2" style="font-size: small">

<b>SocialSecurityAct</b>

</td>

</tr>

<tr class="EditFormHeader">

<td colspan="2" style="font-size: small">

<b>42 CFR</b>

</td>

<td>

<asp:TextBox runat="server" ID="txt42CFR" Text='<%# Bind("42CFR") %>' Enabled="false"/>

</td>

</tr>

<tr class="EditFormHeader">

<td colspan="2" style="font-size: small">

<b>42 USC</b>

</td>

<td>

<asp:TextBox runat="server" ID="txt42USC" Text='<%# Bind("42USC") %>' Enabled="false" />

</td>

</tr>

<tr class="EditFormHeader">

<td colspan="2" style="font-size: small">

<b>Description</b>

</td>

<td>

<asp:TextBox runat="server" ID="txtDescription" Text='<%# Bind("Description") %>' Enabled="false"/>

</td>

</tr>

<tr>

<td align="right" colspan="2">

 

<asp:ImageButton ID="btnUpdate" ImageUrl="~/Img/Update.gif" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'

runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>

</asp:ImageButton>&nbsp;

<asp:ImageButton ID="btnCancel" runat="server" ImageUrl="~/Img/Cancel.gif" CausesValidation="False"

CommandName="Cancel"></asp:ImageButton>

</td>

</tr>

 

</table>

 

</FormTemplate>

</EditFormSettings>

<CommandItemSettings AddNewRecordText="Add " />

</MasterTableView>

</telerik:RadGrid>

</fieldset>

<asp:SqlDataSource ID="GetProvider" runat="server"

 

InsertCommand="spInsert" UpdateCommand="spUpdate"

DeleteCommand="spDelete" DeleteCommandType="StoredProcedure"

InsertCommandType="StoredProcedure" UpdateCommandType="StoredProcedure"

onupdating="GetProvider_Updating"

oninserting="GetProvider_Inserting">

<SelectParameters>

<asp:QueryStringParameter Name="SuspendedProviderId" QueryStringField="SuspendedProviderId"

Type="Int32" />

</SelectParameters>

<InsertParameters>

<asp:QueryStringParameter Name="SuspendedProviderId" QueryStringField="SuspendedProviderId" Type="Int32" />

<asp:Parameter Name="Id" Type="Int32" DefaultValue="1" />

</InsertParameters>

<UpdateParameters>

<asp:Parameter Name="Id" Type="Int32" DefaultValue="1" />

<asp:Parameter Name="SuspendedProviderId" Type="Int32" />

</UpdateParameters>

<DeleteParameters>

<asp:Parameter Name="SuspendedProviderId" />

</DeleteParameters>

</asp:SqlDataSource>

During the insert it passes all the column value , but i just want to pass the insert paramenter value. That means
Just pass these values.

<InsertParameters>

<asp:QueryStringParameter Name="SuspendedProviderId" QueryStringField="SuspendedProviderId" Type="Int32" />

<asp:Parameter Name="Id" Type="Int32" DefaultValue="1" />

</InsertParameters>

Help needed ASAP
Thanks
Eva

2 Answers, 1 is accepted

Sort by
0
Eva
Top achievements
Rank 1
answered on 19 Jul 2011, 11:07 PM
any help on this?
0
Iana Tsolova
Telerik team
answered on 20 Jul 2011, 03:37 PM
Hello Eva,

Try adding the Id field to the DataKeyNames collection and see if this helps.
If not, then you would need to manually set the DefaultValue for the Id parameter in the InsertCommand/ItemCommand event handler.

Greetings,
Iana
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Grid
Asked by
Eva
Top achievements
Rank 1
Answers by
Eva
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or