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

Renaming Directory in radGrid

1 Answer 41 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Aamir asked on 26 Oct 2012, 08:21 PM
I am using a radGrid, on the itemInserted event I have a textbox which takes a name and stores it the table and I am also creating a directory of that name.

Now I am facing problems with renaming the directory I created.
I want to know how I can rename the directory when I want to Edit to change the name. I know this code

System.IO.Directory.Move(@"c:\abc", @"c:\cba");
FileIO.FileSystem.RenameDirectory(oldFolderName.Text, newFolderName.Text)

If I use EditCommand event and find the value of the name column But when I will change the name to something else , How will I take the new value and rename the directory accordingly?

1 Answer, 1 is accepted

Sort by
Jayesh Goyani
Top achievements
Rank 2
answered on 27 Oct 2012, 06:22 PM

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource" OnUpdateCommand="RadGrid1_UpdateCommand">
           <MasterTableView CommandItemDisplay="Top" DataKeyNames="Name" >
                   <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name">
                           <asp:Label ID="Label1" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
                       <asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("Name") %>'></asp:TextBox>
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
            dynamic data = new[] {
              new { ID = 1, Name ="aaa"},
              new { ID = 2, Name = "bbb"},
              new { ID = 3, Name = "ccc"},
              new { ID = 4, Name = "ddd"},
               new { ID = 5, Name ="eee"},
               new { ID = 6, Name ="aaa"},
              new { ID = 7, Name = "bbb"},
              new { ID = 8, Name = "ccc"},
              new { ID = 9, Name = "ddd"},
               new { ID = 10, Name ="eee"}
            RadGrid1.DataSource = data;
        protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
            GridEditableItem item = e.Item as GridEditableItem;
            // Get Old Name
            string strOldName = item.GetDataKeyValue("Name").ToString();
            // Get New Name
            // Using Bound Column
            string strNewName1 = (item["Name"].Controls[0] as TextBox).Text;
            // Using Template column
            string strNewName2 = (item.FindControl("TextBox1") as TextBox).Text;
            // Do Your logic here

Jayesh Goyani
Asked by
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question