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

RadGrid Edit Row + Inline Edit mode

1 Answer 999 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mugdha Aditya
Top achievements
Rank 1
Mugdha Aditya asked on 15 Mar 2012, 07:04 PM

Hello,

http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/alleditablecolumns/defaultcs.aspx
with reference with above link...
i need to use grid with inline edit mode.
My column will be date,report type , description.

After clicking on edit it will convert as dattimepicker, dropdownlist, textbox.

my dropdown will be bind with datatable.

After clik of edit button it will covert in to update and cancel button. i dnt want that. after cllick of edit image it wiill alow data to be edit. and save changes button will be @ botton..

Can you please give me code for above...

Thanks,
Mugdha

 

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 16 Mar 2012, 07:02 AM
Hello Mugdha,

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource"
          OnItemDataBound="RadGrid1_ItemDataBound">
          <MasterTableView CommandItemDisplay="Top" EditMode="InPlace">
              <Columns>
                  <telerik:GridBoundColumn DataField="ID" HeaderText="ID" UniqueName="ID">
                  </telerik:GridBoundColumn>
                  <telerik:GridBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name">
                  </telerik:GridBoundColumn>
                  <telerik:GridEditCommandColumn ButtonType="PushButton">
                  </telerik:GridEditCommandColumn>
              </Columns>
          </MasterTableView>
      </telerik:RadGrid>
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        DateTime dt = new DateTime();
 
        dynamic data = new[] {
                new { ID = 1, Name ="Name1", customdate=dt},
                new { ID = 2, Name = "Name2", customdate=dt},
                new { ID = 3, Name = "Name3", customdate=dt},
                new { ID = 4, Name = "Name4", customdate=dt.AddYears(2011)},
                new { ID = 5, Name = "Name5", customdate=dt}
            };
 
        RadGrid1.DataSource = data;
    }
 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item.IsInEditMode)
        {
            if (e.Item is GridDataInsertItem)
            {
                GridEditableItem editItem = (GridEditableItem)e.Item;
                Button InsertButton = (Button)editItem.FindControl("PerformInsertButton");
                Button CancelButton = (Button)editItem.FindControl("CancelButton");
                CancelButton.Visible = false;
            }
            else
            {
                GridEditableItem editItem = (GridEditableItem)e.Item;
                Button updateButton = (Button)editItem.FindControl("UpdateButton");
                Button CancelButton = (Button)editItem.FindControl("CancelButton");
                updateButton.Text = "save";
 
                CancelButton.Visible = false;
            }
        }
    }



Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Mugdha Aditya
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or