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

[Solved] Insert Record with default value

0 Answers 106 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jignesh
Top achievements
Rank 1
Jignesh asked on 12 Jan 2012, 04:53 PM
I have separate grids, Department and NoteCategory both having ajax databinding. 
On row selection of Department the NoteCategory grid populates for that department.

On Insert command of NoteCategory I have to populate the departmentId for the new NoteCategory record.

How can I fetch the selected DepartmentId from DepartmentGrid and assign to new  record of NoteCategory Grid ?

Department Grid :
<%
    Grid<Hudson.Library.Ui.BusinessObjects.DepartmentTypeListItem> hudsonDeptList = Html.Telerik().Grid<Hudson.Library.Ui.BusinessObjects.DepartmentTypeListItem>()
            .DataBinding(dataBinding => dataBinding
                .Ajax ()
                    .Select("LoadDepartments", "NoteData")
                     .Insert("InsertDepartment", "NoteData")
                    .Update("UpdateDepartment", "NoteData")
                    .Delete("DeleteDepartment", "NoteData")
                    
            )
            .Columns(columns =>
            {
                columns.Bound(c => c.DepartmentId).Width(40).Hidden(true);
                columns.Bound(c => c.DepartmentName).Width(200);
                 
               
                
                columns.Command(commands =>
                {
                commands.Edit().ButtonType(GridButtonType.Text);
                commands.Delete().ButtonType(GridButtonType.Text);
                 }).Width(200).Title("Commands");
                
            }
 
            )
           .Name("HudsonDepartments")
           .Selectable ()
           .DataKeys(dataKeys => dataKeys.Add(c => c.DepartmentId))
           .Pageable(pages => pages.PageSize(20))
           .Footer(true)
           .NoRecordsTemplate("There are no Department to display")
           .ClientEvents(events =>
               {
                   events.OnRowSelected("onRowSelected");
                   events.OnError("onError");
                    
                    
               })
          .ToolBar(commands =>
                {
                    
                        commands.Insert().ButtonType(GridButtonType.ImageAndText);
                }
              )
          
    ;
 
      hudsonDeptList.Render();
    System.IO.StringWriter sw = new System.IO.StringWriter();
    hudsonDeptList.WriteInitializationScript(sw);   
%>
Note Category Grid :
<%
       Grid<Hudson.Library.Ui.BusinessObjects.NoteCategoryItem> noteCategories = Html.Telerik().Grid<Hudson.Library.Ui.BusinessObjects.NoteCategoryItem>()
            .DataBinding(dataBinding => dataBinding
                .Ajax ()
                    .Select("LoadNoteCategories", "NoteData", new { departmentNo = 1})
                     .Insert("InsertNoteCategory", "NoteData" )
                    .Update("UpdateNoteCategory", "NoteData")
                    .Delete("DeleteNoteCategory", "NoteData")
                    
            )
             
            .Columns(columns =>
            {
                columns.Bound(c => c.DepartmentId).Width(40);
                columns.Bound(c => c.NoteCategoryId).Width(200).Hidden();
                columns.Bound(c => c.Description).Width(200);
                 
               
                
                columns.Command(commands =>
                {
                commands.Edit().ButtonType(GridButtonType.Text);
                commands.Delete().ButtonType(GridButtonType.Text);
                 }).Width(200).Title("Commands");
                
            }
 
            )
           .Name("HudsonNoteCategories")
           
           .DataKeys(dataKeys => dataKeys.Add(c => c.NoteCategoryId))
            
           .Pageable(pages => pages.PageSize(20))
           .Footer(true)
           .NoRecordsTemplate("There are no Department to display")
           .ClientEvents(events =>
               {
                   events.OnError("onError");
                   events.OnDataBound("noteCategory_onRowDataBound");
                   events.OnEdit("noteCategory_onEdit");
               })
          .ToolBar(commands =>
                {
                    
                        commands.Insert().ButtonType(GridButtonType.ImageAndText);
                }
              )
          
    ;
 
       noteCategories.Render();
    System.IO.StringWriter sw1 = new System.IO.StringWriter();
    noteCategories.WriteInitializationScript(sw);   
%>

Tags
Grid
Asked by
Jignesh
Top achievements
Rank 1
Share this question
or