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

Not showing editable mode in grid

3 Answers 177 Views
Grid
This is a migrated thread and some comments may be shown as answers.
saradasanthoshi
Top achievements
Rank 1
saradasanthoshi asked on 09 Mar 2011, 04:05 AM
hi
anybody can u  help me. i am new to telerik controls.
i am trying to display a gird in edit mode. (please see this link )
http://www.telerik.com/help/aspnet-ajax/images/grd_EditMode_markedup.png
what should i write in <telerik:GridEditCommandColumn />
this is my code:
<MasterTableView DataKeyNames="configID" AllowAutomaticInserts="true" AllowAutomaticUpdates="true">
                <Columns>
                    <telerik:GridBoundColumn DataField="CONFIGID" HeaderText="ConfigID"
                        UniqueName="ConfigID" DataType="System.Int32" EditFormColumnIndex="1"/>
                    <telerik:GridBoundColumn DataField="CATEGORY" HeaderText="Category"
                        UniqueName="category" DataType="System.String" EditFormColumnIndex="2"/>
                    <telerik:GridBoundColumn DataField="CATEGORY" EditFormColumnIndex="3"
                        DataType="System.String" HeaderText="Category" UniqueName="Category" />
                    <telerik:GridBoundColumn DataField="ITEM" HeaderText="Item"
                        UniqueName="item" DataType="System.String" EditFormColumnIndex="4"/>
                    <telerik:GridBoundColumn DataField="S1" HeaderText="S1"
                        UniqueName="s1" DataType="System.String"  EditFormColumnIndex="5"/>
                    <telerik:GridBoundColumn DataField="S2" HeaderText="S2"
                        UniqueName="s2" DataType="System.String"  EditFormColumnIndex="6"/>
                    <telerik:GridBoundColumn DataField="N1" HeaderText="N1"
                        UniqueName="N1" DataType="System.String"  EditFormColumnIndex="7"/>
                    <telerik:GridBoundColumn DataField="createdwhen" HeaderText="Created When"
                        UniqueName="createdwhen" DataType="System.DateTime"/>
                    <telerik:GridBoundColumn DataField="createdby" HeaderText="Created By"
                        UniqueName="createdby" DataType="System.String"/>
                    <telerik:GridBoundColumn DataField="updatedwhen" HeaderText="Updated When"
                        UniqueName="updatedwhen" DataType="System.DateTime"/>  
<telerik:GridEditCommandColumn />
                </Columns>
                </MasterTableView>
what should i write in this? any idea please
protected void configGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is Telerik.Web.UI.GridEditableItem && e.Item.IsInEditMode)
            {
                //the item is in edit mode
                Telerik.Web.UI.GridEditableItem editedItem = e.Item as Telerik.Web.UI.GridEditableItem;
                //do something here
                
            }
            else if (e.Item is Telerik.Web.UI.GridDataItem)
            {
                //the item is in regular mode
                Telerik.Web.UI.GridDataItem dataItem = e.Item as Telerik.Web.UI.GridDataItem;
                
            }
        }
please help me

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 Mar 2011, 06:43 AM
Hello,

I am not sure about your requirement and I suppose you want to keep the RadGrid first row in edit mode.If so you can try the following code snippet in the PreRender Event..
C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
  {
      GridDataItem item = RadGrid1.MasterTableView.Items[0];//accessing the first row in Grid
      item.Edit = true;                      
      RadGrid1.Rebind();
  }

Also refer the following help article which shows how to access the cells and Rows.
Accessing cells and rows
Thanks,
Shinu.
0
saradasanthoshi
Top achievements
Rank 1
answered on 09 Mar 2011, 05:28 PM
Hi shinu,
thanks for your reply.
Actually i am getting data from database in runtime and displaying in telerik grid with editmode = Inplace. If user click on edit button then all column did change in editable and also should display update and cancel button. I am exactly looking like this(please see the link)
http://www.telerik.com/help/aspnet-ajax/images/grd_EditMode_markedup.png

please help do i need to write editable temple with textboxes, update, cancel or anything else.
If you give an example that will be helpful.
0
Princy
Top achievements
Rank 2
answered on 10 Mar 2011, 11:36 AM
Hello,

GridBoundColumn supports editing of its data and provides, by default, GridTextBoxColumnEditor as a column editor to allow editing the text for each cell when clicking edit button. And Initially, the Grid GridEditCommandColumn displays only an Edit button.When the user presses the edit button, if the table view is configured for in-line editing, the Update and Cancel buttons appear in place of the edit button and the cells on the row become editable. Sample code is given below.

ASPX:
<telerik:RadGrid ID="RadGrid2" AutoGenerateColumns="false" runat="server" DataSourceID="SqlDataSource1">
    <MasterTableView EditMode="InPlace">
        <Columns>
            <telerik:GridEditCommandColumn>
            </telerik:GridEditCommandColumn>
            <telerik:GridBoundColumn DataField="FirstName" HeaderText="FirstName" UniqueName="FirstName">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="total" HeaderText="total" UniqueName="total">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

For more information on column types go through the following documentation.
Column types

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