Hi together,
I have a little problem, i created a Grid with a SQL Data Source. In my Grid I display two Columns, the first is "ClassName from Table tblClass" and the second is "City" from tblCity. The selects are ok. Now if i update a row with this line
the Name will update with the text that i put in the textbox. But i don't know how i can tell to FK_CityID = "selected dropdown value"
In my Dropdown i have the Property ListValueField="PK_City_ID", so that means i have only to replace the fix ID that i have now with the selected dropdown value. But I have no idea how I can do it.
Can someone help me please? thanks a lot
Here is my Code
I have a little problem, i created a Grid with a SQL Data Source. In my Grid I display two Columns, the first is "ClassName from Table tblClass" and the second is "City" from tblCity. The selects are ok. Now if i update a row with this line
UpdateCommand="UPDATE [tblClass] SET [ClassName] = @ClassName, [FK_CityID] = 2 %> WHERE [PK_ClassID] = @original_PK_ClassID" the Name will update with the text that i put in the textbox. But i don't know how i can tell to FK_CityID = "selected dropdown value"
In my Dropdown i have the Property ListValueField="PK_City_ID", so that means i have only to replace the fix ID that i have now with the selected dropdown value. But I have no idea how I can do it.
Can someone help me please? thanks a lot
Here is my Code
<telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True" Skin="Windows7" AllowAutomaticInserts="True" PageSize="10" AllowAutomaticUpdates="True" AllowPaging="True" AutoGenerateColumns="False" DataSourceID="SessionDataSource1" OnItemUpdated="RadGrid1_ItemUpdated" OnItemDeleted="RadGrid1_ItemDeleted" OnItemInserted="RadGrid1_ItemInserted" OnDataBound="RadGrid1_DataBound"> <PagerStyle Mode="NextPrevAndNumeric" /> <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataKeyNames="PK_ClassID" DataSourceID="SessionDataSource1" HorizontalAlign="NotSet" AutoGenerateColumns="False"> <Columns> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"> <ItemStyle CssClass="MyImageButton" /> </telerik:GridEditCommandColumn> <%-- <telerik:GridBoundColumn DataField="PK_ClassID" HeaderText="ID" SortExpression="PK_ClassID" UniqueName="PK_ClassID" ColumnEditorID="GridTextBoxColumnEditor1"> </telerik:GridBoundColumn>--%> <telerik:GridBoundColumn DataField="ClassName" HeaderText="Class Name" SortExpression="ClassName" UniqueName="ClassName" ColumnEditorID="GridTextBoxColumnEditor2"> </telerik:GridBoundColumn> <telerik:GridDropDownColumn DataField="FK_CityID" DataSourceID="SqlDataSource1" HeaderText="City" ListTextField="City" ListValueField="PK_CityID" UniqueName="PK_CityID" ColumnEditorID="GridDropDownColumnEditor1"> </telerik:GridDropDownColumn> <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"> <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" /> </telerik:GridButtonColumn> </Columns> <EditFormSettings ColumnNumber="2" CaptionDataField="FK_CityID" CaptionFormatString="Bearbeiten der Klasse {0}" InsertCaption="Neue Klasse"> <FormTableItemStyle Wrap="False"></FormTableItemStyle> <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle> <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White" Width="100%" /> <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" /> <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> <EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Update record" UniqueName="EditCommandColumn1" CancelText="Cancel edit"> </EditColumn> <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle> </EditFormSettings> </MasterTableView> <ClientSettings> <ClientEvents OnRowDblClick="RowDblClick" /> </ClientSettings> </telerik:RadGrid> <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor1" runat="server" TextBoxStyle-Width="200px" /> <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor2" runat="server" TextBoxStyle-Width="150px" /> <telerik:GridDropDownListColumnEditor ID="GridDropDownColumnEditor1" runat="server" DropDownStyle-Width="110px" /> <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor1" runat="server" NumericTextBox-Width="40px" /> <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager> <br /> <asp:SqlDataSource ID="SessionDataSource1" runat="server" ConnectionString="Server=.\SQLExpress ;Database=IntraIBZ;Trusted_Connection=True;" ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [tblClass]" DeleteCommand="DELETE FROM [tblClass] WHERE [PK_ClassID] = @original_PK_ClassID" InsertCommand="INSERT INTO tblClass(ClassName, FK_CityID) VALUES (@ClassName, @FK_CityID)" UpdateCommand="UPDATE [tblClass] SET [ClassName] = @ClassName, [FK_CityID] = 2 %> WHERE [PK_ClassID] = @original_PK_ClassID" OldValuesParameterFormatString="original_{0}" ConflictDetection="CompareAllValues"> <DeleteParameters> <asp:Parameter Name="original_PK_ClassID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="ClassName" Type="String" /> <asp:Parameter Name="FK_CityID" Type="Int32" /> <asp:Parameter Name="original_PK_ClassID" Type="Int32" /> <asp:Parameter Name="PK_CityID" Type="Int32" /> </UpdateParameters> <InsertParameters> </InsertParameters> </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Server=.\SQLExpress ;Database=IntraIBZ;Trusted_Connection=True;" ProviderName="System.Data.SqlClient" SelectCommand="SELECT [PK_CityID], [City] FROM [tblCity]"> </asp:SqlDataSource> <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> <script type="text/javascript"> function RowDblClick(sender, eventArgs) { sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical()); } </script> </telerik:RadCodeBlock>