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

RadGrid - Add a new record

5 Answers 410 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mani PC
Top achievements
Rank 1
Mani PC asked on 02 May 2012, 12:58 PM

Hello Experts,
I am using Radgrid  - which as Add a new record.

i am using this code to implement Add New Record:
-----------------------------------------

    <CommandItemTemplate > 
      <asp:Button ID="btnInsertRecord" Text="Insert Record"  Runat="server" CommandName="InitInsert"  Height = "25" Width="100" Font-Bold="true" ></asp:Button> 

    </CommandItemTemplate>

-----------------------------------

In the Add mode - The grid columns are  displayed in vertical format(one below the other), can we make it to display in Horizontal format....

If possible please give me sample code...

Thanks

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 May 2012, 01:09 PM
Hello Mani,

Try setting InPlace edit mode to achieve your scenario.
aspx:
<MasterTableView CommandItemDisplay="Top" EditMode="InPlace" >

Thanks,
Shinu.
0
Mani PC
Top achievements
Rank 1
answered on 02 May 2012, 01:21 PM
Thanks for your quick reply.

It aligned it to horizontal.

now i am not seeing save cancel button in add mode... any idea?

-------------------------

<telerik:RadGrid     ID="grdGLAccountsCredit" runat="server" AllowPaging="False" Height="300" SkinID="CenteredWithScroll" Width="400">
                                                                <mastertableview   commanditemdisplay="Top" EditMode="InPlace" >
                                                              
                                                                    <commanditemtemplate> 
                                                                                <asp:Button ID="btnInsertRecord" Runat="server" CommandName="InitInsert" Font-Bold="true"
                                                                                Height="25" Text="Insert Record" Width="100"></asp:Button> 
                                                                    </commanditemtemplate>
                                                                <norecordstemplate>no records retrieved</norecordstemplate>
                                                                <FooterStyle  Font-Bold="True" HorizontalAlign="Right" />
                                                        <Columns>
                                                                <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Edit" ConfirmDialogType="RadWindow" ConfirmTitle="Edit" ImageUrl="~/Images/Edit1.gif"
                                                                Text="Edit" UniqueName="EditColumn">
                                                                    <HeaderStyle Width="20" />                           
                                                                </telerik:GridButtonColumn>
                                                                    <telerik:GridBoundColumn DataField="Percent" HeaderText="Percent"  UniqueName="Percent">     
                                                                                <ItemStyle HorizontalAlign="Right" />                           
                                                                    </telerik:GridBoundColumn>                
                                                                    <telerik:GridBoundColumn DataField="GLCompany" HeaderText="GL Company" UniqueName="GLCompany">        
                                                                            <ItemStyle HorizontalAlign="Right" />                           
                                                                    </telerik:GridBoundColumn>                    
                                                                    <telerik:GridBoundColumn DataField="AccountUnit"  HeaderText="Account Unit" UniqueName="AccountUnit">      
                                                                            <ItemStyle HorizontalAlign="Right" />                           
                                                                    </telerik:GridBoundColumn>                      
                                                                    <telerik:GridBoundColumn DataField="Account" HeaderText="Account"  UniqueName="Account">        
                                                                            <ItemStyle HorizontalAlign="Right" />                           
                                                                    </telerik:GridBoundColumn>                    
                                                                    <telerik:GridBoundColumn DataField="SubAccount"  HeaderText="Sub Account" UniqueName="SubAccount">   
                                                                            <ItemStyle HorizontalAlign="Right" />                           
                                                                    </telerik:GridBoundColumn>                                                         
                                                        </Columns>                  
                                                </mastertableview>
                                            </telerik:RadGrid>          

-------------------------------


Thanks
0
Shinu
Top achievements
Rank 2
answered on 02 May 2012, 01:42 PM
Hello Mani,

Try setting AutoGenerateEditColumn for the RadGrid.
aspx:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateEditColumn="true">
. . . .
</telerik:RadGrid>

Thanks,
Shinu.
0
Mani PC
Top achievements
Rank 1
answered on 02 May 2012, 01:53 PM
Thanks Shinu.

The column width is so small, i can only see Update and not the Cancel...
Now i want to increase the column width (Update/Cancel).. any idea?


Also i have edit button on the grid(left side), i dont want the edit text at the end of the grid to be displayed... i want to hide the edit text..any idea?

Thanks

0
Shinu
Top achievements
Rank 2
answered on 03 May 2012, 12:32 PM
Hello Mani,

In order to show the insert and cancel buttons, you need to hide the Edit links from code behind. Here is the sample code.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
 foreach(GridDataItem item in RadGrid1.Items)
 {
    ((LinkButton)item["AutoGeneratedEditColumn"].Controls[0]).Visible = false;
 }
}

Thanks,
Shinu.
Tags
Grid
Asked by
Mani PC
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mani PC
Top achievements
Rank 1
Share this question
or