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

et Default Textbox Value and DropDown Items in PopUp EditForm

1 Answer 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brett
Top achievements
Rank 2
Brett asked on 28 Apr 2010, 09:11 PM

I have a Formview and a RadGrid on my page.

I am getting details in my RadGrid for the Selected Value in my FormView based on Client ID (cID).
I want to use PopUp edit form. However I am having the following issues when creating new items in my radgird using popup..

1. I need to set the cID in the RadGrid to the current selected value for my FormView.
2. I need on of my columns in Popup Edit form to present a dropdown for ProductID (pID) whiohc ties the dropdown datasource to another lookup table.

I need to hide some of the colums that are  being display in the Insert form of the popup editfiorm as they are not required. But are using in SQL Joins.

Anybody have any clue where to start on any of this?

Pseudo Code for Setting cID
...I know "CurrentMode" dosne't exist for RadGrid...but I don't know where to put this.

 Protected Sub RadGrid1_PreRender(ByVal sender As ObjectByVal e As EventArgs)  
        Dim strCID As String = fvClients.SelectedValue  
        If RadGrid.CurrentMode = RadGrid.Insert AndAlso (DirectCast(RadGrid.FindControl("cIDTextBox"), TextBox)).Text.Length = 0 Then 
            Dim tbox As TextBox = TryCast(RadGrid1.FindControl("cIDTextBox"), TextBox)  
            tbox.Text = strCID  
        End If 
    End Sub 

Also how do I change pID column to dropdown with different datasource? And how to do I hide "Name" column in Insert/Edit Forms?
  <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="dsPrescriptionItems" 
                        GridLines="None" AutoGenerateEditColumn="True" AutoGenerateColumns="False" Skin="Forest">  
                        <HeaderContextMenu EnableAutoScroll="True">  
                        </HeaderContextMenu> 
                        <MasterTableView DataKeyNames="ID" DataSourceID="dsPrescriptionItems" AllowAutomaticDeletes="True" 
                            AllowAutomaticInserts="True" AllowAutomaticUpdates="True" CommandItemDisplay="Bottom" 
                            EditMode="PopUp">  
                            <Columns> 
                                <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" Display="False" HeaderText="ID" 
                                    ReadOnly="True" SortExpression="ID" UniqueName="ID">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="cID" DataType="System.Int32" Display="False" 
                                    HeaderText="cID" SortExpression="cID" UniqueName="cID">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="pID" DataType="System.Int32" Display="False" 
                                    HeaderText="pID" SortExpression="pID" UniqueName="pID">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name" 
                                    UniqueName="Name">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="ScriptRefills" DataType="System.Int32" HeaderText="Refills" 
                                    SortExpression="ScriptRefills" UniqueName="ScriptRefills">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="StartDate" DataFormatString="{0:MMM dd, yyyy}" 
                                    DataType="System.DateTime" HeaderText="Start Date" SortExpression="StartDate" 
                                    UniqueName="StartDate">  
                                </telerik:GridBoundColumn> 
                            </Columns> 
                            <EditFormSettings CaptionFormatString="Edit Prescription" 
                                InsertCaption="Add Prescription:" PopUpSettings-Modal="True">  
                                <PopUpSettings Modal="True" /> 
                            </EditFormSettings> 
                        </MasterTableView> 
                        <ClientSettings> 
                            <ClientEvents OnPopUpShowing="PopUpShowing" /> 
                            <Selecting AllowRowSelect="true" /> 
                        </ClientSettings> 
                    </telerik:RadGrid> 

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 29 Apr 2010, 04:47 PM
Hello Brett,

For your convenience I've created sample application. At the top there is FormView bound to  Customers table from Northwind via LinqDataSource.

Bellow FormView control there is RadGrid that is bound to Orders and shows the records only for those Orders that match the CustomerID from FormView. You can perform Insert on new Order in RadGrid and CustomerID of the new item will be automatically inserted.

I hope this helps.

Regards,
Nikolay
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Brett
Top achievements
Rank 2
Answers by
Nikolay Rusev
Telerik team
Share this question
or