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

[Solved] Using a user control to enter in edit mode

1 Answer 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hadar Kaufman
Top achievements
Rank 1
Hadar Kaufman asked on 20 Dec 2009, 09:55 AM
Hi Telerik,
i saw your example of using a user control in RadGrid to mmake a custom edit mode and I have some wuestions about it:
1. in the user control, i want to have access in the code behind to the recieved data item. how can i do that?
2. The reason i ask it is because i didn't manage to perform more complicated data binding in the user control. I wanted to bind a dropdown list to one of the dataItem fields. this is the full dataItem that is returened by the datasource in the main grid:
 public DataView Fill() 
        { 
            //DataView dv = new DataView(); 
 
            //dv.Table.DataSet.Tables.Add("tbl999"); 
            DataTable dt = new DataTable("tbl999"); 
             
            dt.Columns.Add(new DataColumn("Title")); 
            dt.Columns.Add(new DataColumn("isCombo")); 
            dt.Columns.Add(new DataColumn("options")); 
 
 
             
            for (int i = 0; i < 10; i++) 
            { 
                DataTable dtInner = new DataTable("dtInner "+i); 
 
                dtInner.Columns.Add(new DataColumn("optionValue")); 
                dtInner.Columns.Add(new DataColumn("optionTitle")); 
                for(int j=0;j<i;j++){ 
                    dtInner.Rows.Add(j,"option " + j); 
                } 
                DataView dvInner = dtInner.DefaultView; 
                dt.Rows.Add("Question number " + i, Convert.ToBoolean(i % 2), dvInner); 
            } 
            DataView dv = dt.DefaultView; 
            return dv; 
        } 
and in my user control, i tried to Bind / Eval it in the ASCX side:
  <td style="width: 50%"
                            <asp:Label ID="lblOptionTitle" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Title") %>'></asp:Label> 
                        </td> 
             <asp:DropDownList runat="server" DataSource='<%# DataBinder.Eval(Container, "DataItem.options") %>' OnDataBinding="dropdownlist2_DataBound" 
                                ID="dropdownlist2" AppendDataBoundItems="true" DataTextField="optionTitle" DataValueField="optionValue" DataMember="options"
                            </asp:DropDownList>           <td style="width: 50%"
 </td> 

but the second Eval doesn't work.

3. To make things more neat, is it possible to user DetailsView in the edited user control and use it's events? Can you please demonstrate how to bind it to the returned data item? do you have a better recommendation for this use?

Thanks,
Hadar

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 21 Dec 2009, 04:29 PM
Hi Hadar,

Please take a look at the following resources demonstrating how the desired by you functionality can be achieved:
Accessing cells and rows (Accessing the value of cells in edit mode section)
Custom edit forms
Customize/Configure GridDropDownColumn

Let me know whether you find them useful.

Regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Hadar Kaufman
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or