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

How to change popup fields length ???

10 Answers 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gert Petersen
Top achievements
Rank 1
Gert Petersen asked on 16 Dec 2009, 10:46 AM
Hi,

I am using a grid with a popup ( to edit/delete/add new records )
editformtype = autogenerated

Is it possible to change the length of the fields in the popup window ???
and how ?
a screendump is attached ?

Br
Pettsen

10 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Dec 2009, 11:30 AM
Hi,

Try the following code snippet in order to change the width of the textboxes shown in the EditForm.

CS:
 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode) 
        { 
            GridEditFormItem editItem = (GridEditFormItem)e.Item; 
            TextBox textbox = (TextBox)editItem["ColumnUniqueName"].Controls[0]; 
            textbox.Width = Unit.Pixel(250); 
        } 
    } 

-Shinu.
0
Gert Petersen
Top achievements
Rank 1
answered on 16 Dec 2009, 11:56 AM

Thanks for the quick answer,

GREAT.............. Now it works.

1000 thanks, and a merry christmas to you, you saved mine. :-)

Br
Pettsen

 

0
Gert Petersen
Top achievements
Rank 1
answered on 17 Dec 2009, 07:05 AM


        <telerik:RadGrid ID="RadGrid10" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" 
            AllowAutomaticUpdates="True" AllowPaging="True" DataSourceID="SqlDataSource10" 
            GridLines="None" Skin="Outlook" PageSize="20" AutoGenerateColumns="False">  
            <MasterTableView CommandItemDisplay="Top" DataKeyNames="ID" DataSourceID="SqlDataSource10" 
                EditMode="popup">  
                <RowIndicatorColumn>  
                    <HeaderStyle Width="20px" />  
                </RowIndicatorColumn>  
                <ExpandCollapseColumn>  
                    <HeaderStyle Width="20px" />  
                </ExpandCollapseColumn>  
                <Columns>  
                    <telerik:GridEditCommandColumn>  
                    </telerik:GridEditCommandColumn>  
                    <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="column">  
                    </telerik:GridButtonColumn>  
                    <telerik:GridBoundColumn DataField="ID" DataType="System.Int64" DefaultInsertValue="" 
                        HeaderText="ID" ReadOnly="True" SortExpression="ID" UniqueName="ID">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn DataField="LeverandorNavn" DefaultInsertValue="" HeaderText="LeverandorNavn" 
                        SortExpression="LeverandorNavn" UniqueName="LeverandorNavn">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn DataField="Email" DefaultInsertValue="" HeaderText="Email" 
                        SortExpression="Email" UniqueName="Email" Resizable="True" DataType="System.String">  
                    </telerik:GridBoundColumn>  
                </Columns>  
                <EditFormSettings EditFormType="Template">  
                    <EditColumn UniqueName="EditColumn">  
                    </EditColumn>  
                    <FormTemplate>  
                        <table border="0" cellpadding="2">  
                            <tr>  
                                <td>  
                                    Category Name:&nbsp;  
                                </td>  
                                <td>  
                                    <asp:TextBox ID="txtname" Width="250px" Text='<%# Bind( "LeverandorNavn") %>' runat="server"></asp:TextBox>  
                                </td>  
                            </tr>  
                            <tr>  
                                <td>  
                                    Description:&nbsp;  
                                </td>  
                                <td>  
                                    <asp:TextBox ID="txtemail" Width="250px" Text='<%# Bind( "Email") %>' runat="server"></asp:TextBox>  
                                </td>  
                            </tr>  
                        </table>  
                        <asp:Button ID="btnUpdate" CommandName="Update" Text="Update" runat="server" />  
                        <asp:Button ID="btnCancel" CommandName="Cancel" Text="Cancel" runat="server" />  
                    </FormTemplate>  
                </EditFormSettings>  
            </MasterTableView>  
        </telerik:RadGrid>  
        <br />  
        <asp:SqlDataSource ID="SqlDataSource10" runat="server" ConnectionString="<%$ ConnectionStrings:ECOConnectionString2 %>" 
            SelectCommand="SELECT * FROM [Leverandor] ORDER BY [LeverandorNavn]" DeleteCommand="DELETE FROM [Leverandor] WHERE [ID] = @ID" 
            InsertCommand="INSERT INTO [Leverandor] ([LeverandorNavn], [Email]) VALUES (@LeverandorNavn, @Email)" 
            UpdateCommand="UPDATE [Leverandor] SET [LeverandorNavn] = @LeverandorNavn, [Email] = @Email WHERE [ID] = @ID">  
            <DeleteParameters>  
                <asp:Parameter Name="ID" Type="Int64" />  
            </DeleteParameters>  
            <UpdateParameters>  
                <asp:Parameter Name="LeverandorNavn" Type="String" />  
                <asp:Parameter Name="Email" Type="String" />  
                <asp:Parameter Name="ID" Type="Int64" />  
            </UpdateParameters>  
            <InsertParameters>  
                <asp:Parameter Name="LeverandorNavn" Type="String" />  
                <asp:Parameter Name="Email" Type="String" />  
            </InsertParameters>  
        </asp:SqlDataSource> 

Hi again,
If i use a template to edit the grid, how can i insert records.
Edit and delete works fine, see code.

Br
Pettsen
0
Princy
Top achievements
Rank 2
answered on 17 Dec 2009, 09:17 AM
Hello Gert,

Here's the link to an online demo which demonstrates on how to insert records when using a form template. This should probably help you out.
Form Template Edit Form

Thanks
Princy.
0
Gert Petersen
Top achievements
Rank 1
answered on 17 Dec 2009, 09:55 AM
Thank you VERY much, but i get theese errors, see attached image:

0
Sebastian
Telerik team
answered on 17 Dec 2009, 12:50 PM
Hi Gert,

 I suppose you write in VB.NET language - if so, you will need to use the binding expresion syntax from the DefaultVB.aspx tab of the online example.


Best,
Sebastian
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
Gert Petersen
Top achievements
Rank 1
answered on 17 Dec 2009, 01:32 PM
So, it isn't possible to do it without coding ?
( i am trying to keep it as simple as possible )

Br
Gert
0
Sebastian
Telerik team
answered on 17 Dec 2009, 03:48 PM
Hello Gert,

The minimal code you can have for this purpose is the conditional binding expression in question.


Regards,
Sebastian
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
Gert Petersen
Top achievements
Rank 1
answered on 17 Dec 2009, 05:53 PM
Sorry if i seem stupid, but can you please mark the code you mean with:
" conditional binding expression in question"

Thanks...

Br
Gert
0
Princy
Top achievements
Rank 2
answered on 29 Dec 2009, 01:58 PM
Hello Gert,

Replace the binding expression of the button using its VB version as shown below:
aspx:
<asp:Button ID="Button1" Text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "Insert", "Update") %>'   
 runat="server" CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update")%>' > 
</asp:Button> 

Hope this helps..
Princy.
Tags
Grid
Asked by
Gert Petersen
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Gert Petersen
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Sebastian
Telerik team
Share this question
or