hello,
i'm testing out 2 controls, the radgrid and the RadComboBox, i'm created a custom edit form using web form user control (ascx) onto which i add labels, textboxes and and dropdownlists, however i'm getting a weird behaviour, this is the expected behaviour:
--- the first dropdown(1) needs to be filled with for example "None,A,B,C,D,E,F,G" while the second dropdown(2) needs to be filled with for example "None,F1,F2,F3,F4,F5,F6"
however what i'm getting is:
--- the first dropdown(1) is filled with "None,F1,F2,F3,F4,F5,F6" and has the correct index while the second dropdown(2) is also filled with "None,F1,F2,F3,F4,F5,F6" and has the correct selected item, which means that the data binding i made to the first dropdown list is overwritten somewhere with the items from the last dropdown created.
if i run the application on debug mode, everything's ok but when the custom edit form opens, all the combos have the exact same items in them, here's my code for creating and adding controls
details.ascx
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="Details.ascx.vb" Inherits="Project.Details" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<
div
id
=
"template_edit"
style
=
"background-color:red"
runat
=
"server"
>
<%-- div onto which all my controls are addded --%> </
div
>
<
div
id
=
"editfooter"
>
<
asp:Button
ID
=
"Button_aceitar"
Text
=
"Update"
runat
=
"server"
CommandName
=
"Update"
Visible
=
"true"
></
asp:Button
>
<
asp:Button
ID
=
"Button2"
Text
=
"Insert"
runat
=
"server"
CommandName
=
"PerformInsert"
Visible
=
"true"
></
asp:Button
>
<
asp:Button
ID
=
"Button_cancelar"
Text
=
"Cancelar"
runat
=
"server"
CausesValidation
=
"False"
CommandName
=
"Cancel"
></
asp:Button
>
<
asp:Label
ID
=
"LabelLOG"
runat
=
"server"
Text
=
"Label"
Visible
=
"False"
></
asp:Label
>
</
div
>
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
If
IsPostBack
Then
Try
sOper = Session(
"OPERACAO_Edit"
)
gPeriodo = Session(
"PERIODO_Edit"
)
gClasse = Session(
"CLASSE_Edit"
)
gSistema = Session(
"SISTEMA_Edit"
)
Catch
ex
As
Exception
End
Try
gEG = Session(
"EntidGest"
)
Select
Case
gClasse & gSistema
Case
11
gMNID = 1
Case
12
gMNID = 2
Case
21
gMNID = 3
Case
22
gMNID = 4
Case
31
gMNID = 5
Case
32
gMNID = 6
End
Select
Add_Controls(sOper)
Else
gPeriodo = Request.QueryString(
"periodo"
)
gClasse = Request.QueryString(
"classe"
)
gSistema = Request.QueryString(
"sistema"
)
gEG = Session(
"EntidGest"
)
Select
Case
gClasse & gSistema
Case
11
gMNID = 1
Case
12
gMNID = 2
Case
21
gMNID = 3
Case
22
gMNID = 4
Case
31
gMNID = 5
Case
32
gMNID = 6
End
Select
End
If
Catch
ex
As
Exception
End
Try
End
Sub
Private
Sub
Detail_PreInit(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Init
Try
gVALIDATETEXT =
"a-záâàãéêèíîìóôòõúûùçA-ZÁÂÀÃÉÊÈÍÎÌÓÔÒÕÚÛÙÇ .,;:/+\?!0-9<>_=&-"
gVALIDATETEXT = gVALIDATETEXT.Replace(
"a-z"
,
""
)
gVALIDATETEXT = gVALIDATETEXT.Replace(
"A-Z"
,
""
)
gVALIDATETEXT = gVALIDATETEXT.Replace(
"0-9"
,
""
)
Catch
ex
As
Exception
gText = System.Reflection.MethodBase.GetCurrentMethod().Name &
" Erro: "
&
Me
.Page.ToString &
" "
& ex.Message
Add2LogFile(glogpath, gText)
End
Try
End
Sub
Private
Sub
Add_Controls(
ByVal
bOper
As
String
)
'this bit of code is inside a loop that goes through some metadata, creates and adds controls to a div
Dim
oCmb
As
New
RadDropDownList
Dim
oTextBox
As
New
TextBox
Dim
gSqlCMB
As
New
SqlDataSource
Dim
sValue as
String
oCmb =
New
RadDropDownList
oCmb.ID =
'something dynamic
gSQL =
"select c,t from table"
'the query is different for each dropdownlist
gSqlCMB.SelectCommand = gSQL
oCmb.DataSource = gSqlCMB
oCmb.DataValueField =
"C"
oCmb.DataTextField =
"T"
oCmb.DataBind()
ocmb.SelectedIndex = sValue
'"1", "2", "3"....
template_edit.controls.Add(oCmb)
if
(e.keyCode == 13) {
var
masterTable = $find(
"<%= grd.ClientID %>"
).get_masterTableView();
masterTable.fireCommand(
"PerformInsert"
,
""
);
}
if
(e.keyCode == 27) {
var
masterTable = $find(
"<%= grd.ClientID %>"
).get_masterTableView();
masterTable.fireCommand(
"Cancel"
,
""
);
}