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

Dataform insert bind RadDropDownList

3 Answers 201 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 21 Jun 2016, 11:02 AM

Hi

My DataForm displays data in edit mode just fine, with a selection of textboxs and RadDropDownList's.

The RadDropDownList bind via the RadDataForm1_ItemDataBound event.

 

But when I am in insert mode how do I populate/bind  my  RadDropDownList in code behind?

The ItemDataBound doesn't fire

 

Many Thanks

 

Mark

 

3 Answers, 1 is accepted

Sort by
0
Mark
Top achievements
Rank 1
answered on 21 Jun 2016, 03:45 PM

This seems to work using ItemCreated event.

But is this the correct way to bind?

 

Thanks

MArk

 Private Sub RadDataForm1_ItemCreated(sender As Object, e As RadDataFormItemEventArgs) Handles RadDataForm1.ItemCreated
        If TypeOf e.Item Is IRadDataFormInsertItem Then
            Dim item As RadDataFormEditableItem = TryCast(e.Item, RadDataFormEditableItem)
            'Dim textBox As TextBox = TryCast(item.FindControl("CompanyNameTextBox"), TextBox)
       end if



            Dim RadDropDownListlicense As RadDropDownList = DirectCast(item.FindControl("RadDropDownListlicense"), RadDropDownList)
            RadDropDownListlicense.DataSource = objWedData.GetDataTable("SELECT l_ir,l_name FROM license")
            RadDropDownListlicense.DataTextField = "l_name"
            RadDropDownListlicense.DataValueField = "l_ir"
            RadDropDownListlicense.DataBind()

0
Mark
Top achievements
Rank 1
answered on 22 Jun 2016, 08:07 AM

Hi again.

Would there be an example of a the Dataform being used in quite a detailed way? Most if not all the examples are quite basic.

I went down the route of data binding without using datasource objects and binding with code behind. 

What i'm finding with this control and others, is that i'm using work rounds and jarvascript more and more as the site grows.

What worries me is that my approach may be wrong. It would be good to see an example that uses telerik asp controls in a more real life way.

No worries if not.

 

Thanks

 

Mark

0
Eyup
Telerik team
answered on 24 Jun 2016, 08:45 AM
Hi Mark,

You can use the DataBinding event handler of the combo to achieve this requirement. You can check the sample provided in the following article for a sample web site with RadDataForm:
http://www.telerik.com/support/code-library/accessing-controls-in-dataform

I am also sending another web site to demonstrate a more advanced scenario.

I hope this will prove helpful.

Regards,
Eyup
Telerik
Tags
DataForm
Asked by
Mark
Top achievements
Rank 1
Answers by
Mark
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or