Good day,
I have the following. I have a dropdownlist control in an Insert view mode. I need that my dropdownlist populates a pair of textbox controls from the database in the same view. I'm using the ddlEntityTypeFilter_SelectedIndexChanged event in order to do it. However I have got an error during the process since the Texbox control is returning a null value then I haven't been able to populate the texbox controls. Actually I need to populate Encargado2 and Email2 textbox controls.
Here is the aspx file:
And the code behind:
Any suggestion?
Thanks in advance
William
I have the following. I have a dropdownlist control in an Insert view mode. I need that my dropdownlist populates a pair of textbox controls from the database in the same view. I'm using the ddlEntityTypeFilter_SelectedIndexChanged event in order to do it. However I have got an error during the process since the Texbox control is returning a null value then I haven't been able to populate the texbox controls. Actually I need to populate Encargado2 and Email2 textbox controls.
Here is the aspx file:
<
telerik:GridTemplateColumn
UniqueName
=
"Nombre"
DataField
=
"Nombre"
HeaderText
=
"Nombre del Area"
ForceExtractValue
=
"InEditMode"
ConvertEmptyStringToNull
=
"true"
>
<
EditItemTemplate
>
<
asp:DropDownList
CssClass
=
"dropdownlist"
ID
=
"ddlNombre"
runat
=
"server"
AutoPostBack
=
"true"
OnSelectedIndexChanged
=
"ddlEntityTypeFilter_SelectedIndexChanged"
></
asp:DropDownList
>
<
asp:Label
ID
=
"LabelNombre"
runat
=
"server"
Text='<%#Eval("Nombre") %>'></
asp:Label
>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:Label
ID
=
"LabelNombre"
runat
=
"server"
Text='<%#Eval("Nombre") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"Encargado"
DataField
=
"Encargado"
HeaderText
=
"Encargado"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"Email"
DataField
=
"Email"
HeaderText
=
"Email"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"Encargado2"
DataField
=
"Encargado2"
HeaderText
=
"Encargado2"
ForceExtractValue
=
"InEditMode"
ConvertEmptyStringToNull
=
"true"
Visible
=
"false"
>
<%-- <
ItemTemplate
>
<
asp:Label
ID
=
"LabelEncargado2"
runat
=
"server"
Text='<%#Eval("Encargado2") %>'></
asp:Label
>
</
ItemTemplate
>--%>
<
EditItemTemplate
>
<
asp:TextBox
ID
=
"TextBoxEncargado2"
runat
=
"server"
></
asp:TextBox
>
<
asp:Label
ID
=
"LabelEncargado2"
runat
=
"server"
Text='<%#Eval("Encargado2") %>'></
asp:Label
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"Email2"
DataField
=
"Email2"
HeaderText
=
"Email2"
ForceExtractValue
=
"InEditMode"
ConvertEmptyStringToNull
=
"true"
Visible
=
"false"
>
<%-- <
ItemTemplate
>
<
asp:Label
ID
=
"LabelEmail2"
runat
=
"server"
Text='<%#Eval("Email2") %>' ></
asp:Label
>
</
ItemTemplate
>--%>
<
EditItemTemplate
>
<
asp:TextBox
ID
=
"TextBoxEmail2"
runat
=
"server"
></
asp:TextBox
>
<
asp:Label
ID
=
"LabelEmail2"
runat
=
"server"
Text='<%#Eval("Email2") %>'></
asp:Label
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
protected
void
ddlEntityTypeFilter_SelectedIndexChanged(
object
sender, EventArgs e)
{
DropDownList dropdown = (DropDownList)sender;
string
value = dropdown.SelectedValue;
SpecialTablesController sp =
new
SpecialTablesController();
GridEditFormInsertItem edititem = (GridEditFormInsertItem)dropdown.NamingContainer;
TextBox TextBoxID = (TextBox)edititem.FindControl(
"Encargado2"
); -> TextboxID is null
Dependencia obj = sp.GetDependencyValues(dropdown.SelectedValue);
TextBoxID.Text = obj.Encargado;-> I got the error here NullReferenceException
TextBoxID.Text = obj.EMail;
}
Thanks in advance
William