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

Radgrid - Populate values in UserControl used for Insert

2 Answers 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Badhri Narayanan
Top achievements
Rank 1
Badhri Narayanan asked on 07 Jan 2016, 09:26 PM

I have a page "Tracking.aspx" which loads a Radgrid with employee work details(say id(hidden),employee_id, employee_name, hours_worked, date_worked)

Example entries:

id     employee_id    employee_name     hours_worked     date_worked

1         1                              Emp1                          5                 1/1/2015

2         1                              Emp1                          2                 2/1/2015

3         2                              Emp2                          6                 1/1/2015

4         2                              Emp2                          8                 2/1/2015

 

Now, I'm trying to add a functionality to this page. If the user wants to make a new entry very similar to id '4', then he has to click on the Employee_name column of that row, which will open the page in insert mode(we have a separate user control for Insert, "TrackingAddForm.ascx"), with the details of the id '4' populated in it.

This is what I have done so far: 

1)  I have managed to change the employee name column from 'telerik:GridBoundColumn' into 'telerik:GridHyperLinkColumn' 

<telerik:GridHyperLinkColumn DataTextField ="Employee" DataNavigateUrlFields = "ID" DataNavigateUrlFormatString="Tracking.aspx?blank=Employee&id={0}"
                        FilterControlAltText="Filter Employee column" HeaderText="Employee" 
                        SortExpression="Employee" UniqueName="Employee">

 2) When this link is clicked, I'm collecting the ID from the Request.QueryString and fetching the data for the corresponding ID.

 3) I have opened the same "Tracking.aspx" page in the Insert Mode, so that the user control "TrackingAddForm.ascx" is shown in the "Tracking.aspx". (used the below code)

protected void RadGrid1_PreRender(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {                
                RadGrid1.MasterTableView.IsItemInserted = true;
                RadGrid1.Rebind();
            }
        }

 

Now what I'm NOT ABLE to do is:

4) Populate the fields of the user control "TrackingAddForm.ascx" with the data fetched in step (2).

 

So my question is,

a) While opening the page in Insert Mode(by clicking a 'GridHyperLinkColumn' Employee), is there a way to populate the fields of the Insert UserControl ? 

b) If any of the above steps I have taken is wrong or if there is a better approach to do the same thing, please let me know.

 

Thanks in Advance

2 Answers, 1 is accepted

Sort by
0
Badhri Narayanan
Top achievements
Rank 1
answered on 08 Jan 2016, 03:40 PM
Anyone?
0
Eyup
Telerik team
answered on 12 Jan 2016, 03:16 PM
Hello Badhri,

You can check the following live sample to see how you can configure editing with User Control:
http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/edit-form-types/defaultcs.aspx

And you can download an isolated runnable version here:
http://www.telerik.com/forums/need-help-with-radgrid-edititemtemplate#URBPnAh7v0ihfP0Dlu6LAA

Hope this helps.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Badhri Narayanan
Top achievements
Rank 1
Answers by
Badhri Narayanan
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or