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

user control edit form

6 Answers 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
amir sherafatian
Top achievements
Rank 1
amir sherafatian asked on 03 Oct 2009, 10:06 AM
i have a RadComboBox and some TextBoxes in a UserControl that i use this UserControl as UserControlEditFrom in a Radgrid ,
when i go to edit mode from grid i need to bind the my combo box to own current value from DataBase,
in same cases about text boxes i use this code (like your example here : http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/usercontroleditform/defaultcs.aspx ) to bind text property of my text box :

<asp:TextBox Text=<%# DataBinder.Eval( Container, "DataItem.Title" ) %> ID="TextBoxTitle" runat="server"></asp:TextBox>

but about my combo box !!!!!!!!!!! what shoud i do ?

i search your example (http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/usercontroleditform/defaultcs.aspx ) but you dont use any line of code to bind combo but it work when i test your sample by editing different row of grid !!!!!!!!
what you do ? and what does it work ?

it is a part of your code front of your project that i think in the bold line you should have use anything to bind combo like textboxes :

<tr>
                    <td>Birth Date:</td>
                    <td>
<asp:TextBox id="TextBox11" runat="server"
Text='<%# DataBinder.Eval( Container, "DataItem.BirthDate") %>'
                         tabIndex=4>
                        </asp:textbox></td>
                </tr>
                <tr>
                    <td>Title Of Courtesy</td>
                    <td>
                        <asp:dropdownlist id="ddlTOC" runat="server" tabindex="7"></asp:dropdownlist></td>
                </tr>
            </table>
        </td>
        <td>

6 Answers, 1 is accepted

Sort by
0
amir sherafatian
Top achievements
Rank 1
answered on 04 Oct 2009, 07:52 AM
how can i bind a combo in user control edit form to its own value from database ???
0
Princy
Top achievements
Rank 2
answered on 05 Oct 2009, 07:08 AM
Hello Amir,

You can set the DataSourceId of your dropdownlist to the Id of the DataSourceControl with which the grid is bound and then set the DataTextField and DataValueField properties of the dropdownlist to the corresponding datafield. Check out the example given below:

aspx:
<asp:DropDownList ID="ddlTOC" runat="server" DataSourceID="SqlDataSource1"  
DataTextField="TitleOfCourtesy" DataValueField="TitleOfCourtesy" tabindex="7"
</asp:DropDownList> 

Thanks
Princy.
0
amir sherafatian
Top achievements
Rank 1
answered on 05 Oct 2009, 12:51 PM
tanks princy you right but
my combobox is in user control edit form of a rad grid that i need to bind it to a item that it want be edit
i guess i need a thing like this :
 <asp:TextBox Text=<%# DataBinder.Eval( Container, "DataItem.Title" ) %> ID="TextBoxTitle" runat="server"></asp:TextBox>
0
amir sherafatian
Top achievements
Rank 1
answered on 07 Oct 2009, 06:35 AM
is there any body here to give me help about that ?????????????????????????????

how your sample that i mentioned above work when it is incorrect ?

what can i do for my problem ?
0
Princy
Top achievements
Rank 2
answered on 07 Oct 2009, 07:37 AM
Hi Amir,

You can set the SelectedValue property for the dropdownlist in the user control as shown below:
aspx:
<asp:DropDownList ID="ddlTOC" runat="server" DataSourceID="SqlDataSource1"   
DataTextField="TitleOfCourtesy" DataValueField="TitleOfCourtesy" 
SelectedValue='<%#DataBinder.Eval(Container, "DataItem.TitleOfCourtesy") %>' tabindex="7">  
</asp:DropDownList>  

Thanks
Princy.
0
amir sherafatian
Top achievements
Rank 1
answered on 07 Oct 2009, 10:21 AM
tanks princy for your regard
you told me the first thing that i thought to do but
i have no access to the "SelectedValue" property of RadComboBox and asp DropDown in CodeFront
although i use RadComboBox,
do you have other idea ?
Tags
Grid
Asked by
amir sherafatian
Top achievements
Rank 1
Answers by
amir sherafatian
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or