H
Hollywood
I have a formview control that contains a dropdownlist (nested in a
panel) and I want to set the visible property to False when the user
is in a particular role. I'm using a modal popup button click event
to fire the change, and I set the formview mode to Insert and that
works great. Just after that I try to set the dropdownlist.visible =
false (or true depending) and I can find the control okay but it never
sets the visibility.
I've been chasing after this for a couple of days and any help would
really be appreciated!!
Here's the code:
aspx page:
<asp:FormView ID="FormView1" runat="server" DataSourceID="Dealer"
Width="27%">
<InsertItemTemplate>
<table id="InsertItemTable" runat="server" style="width: 656px">
<tr>
<td style="width: 703px">
<asp
anel ID="InsertDealerInfoPanel" runat="server"
GroupingText="Dealer Info" Width="700px">
<table id="InsertDealerInfoTable" runat="server"
style="width: 672px">
<tr>
<td style="width: 138px">
OGC ID:
</td>
<td style="width: 214px">
<asp:Label ID="OGCIDLabel" runat="server" Text='New'></
asp:Label>
</td>
</tr>
<tr>
<td style="width: 138px">
Contact Name:</td>
<td style="width: 214px">
<asp:TextBox ID="NameTextBox" runat="server" Text='<%#
Bind("Name") %>' Width="300px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="NameTextBox"
Display="Dynamic" ErrorMessage="Contact Name is reqired."
ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 138px">
Company Name:</td>
<td style="width: 214px">
<asp:TextBox ID="CompanyTextBox" runat="server" Text='<%#
Bind("Company") %>' Width="300px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 138px">
Company Type:</td>
<td style="width: 214px">
<asp:RadioButton ID="CorporationRadioBtn" runat="server"
GroupName="BusinessType" Text="Corporation" />
<asp:RadioButton ID="NonCorporationRadioBtn"
runat="server" GroupName="BusinessType" Text="Non-Corporate Entity" /
Eval("Is_1099") %>' Visible="False"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 138px; height: 26px;">
Phone:</td>
<td style="width: 214px; height: 26px;">
<asp:TextBox ID="PhoneTextBox" runat="server" Text='<%#
Bind("Phone") %>' Width="152px" MaxLength="10"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator4"
runat="server" ControlToValidate="PhoneTextBox"
Display="Dynamic" ErrorMessage="Phone is required."
ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 138px">
Fax:</td>
<td style="width: 214px">
<asp:TextBox ID="FaxTextBox" runat="server" Text='<%#
Eval("FaxNumber") %>' Width="152px" MaxLength="10"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 138px">
Cell Phone:</td>
<td style="width: 214px">
<asp:TextBox ID="CellPhoneTextBox" runat="server" Text='<
%# Eval("CellPhone") %>' Width="152px" MaxLength="10"></asp:TextBox></
td>
</tr>
<tr>
<td style="width: 138px">
Email Address:</td>
<td style="width: 214px">
<asp:TextBox ID="EmailTextBox" runat="server" Text='<%#
Eval("EmailAddress") %>' Width="300px"></asp:TextBox><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator5"
runat="server" ControlToValidate="EmailTextBox"
Display="Dynamic" ErrorMessage="Email Address is
required." ValidationGroup="Insert"></
asp:RequiredFieldValidator><asp:RegularExpressionValidator
ID="RegularExpressionValidator1" runat="server"
ControlToValidate="EmailTextBox"
Display="Dynamic" ErrorMessage="You must enter a valid
email address." Width="296px" ValidationExpression="\w+([-+.']\w+)*@\w+
([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td style="width: 138px">
Tax ID or Social Security:</td>
<td style="width: 214px">
<asp:TextBox ID="TaxIDTextBox" runat="server" Text='<%#
Eval("TaxID") %>' Width="152px" MaxLength="9"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator6"
runat="server" ControlToValidate="TaxIDTextBox"
Display="Dynamic" ErrorMessage="Please enter a valid
Federal Tax ID or SS Number." ValidationGroup="Insert" Width="376px"></
asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 138px;
height: 26px">
User ID:</td>
<td style="width: 214px;
height: 26px">
<asp:TextBox
ID="UserIDTextBox" runat="server"></asp:TextBox><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
runat="server" ControlToValidate="UserIDTextBox"
Display="Dynamic"
ErrorMessage="User ID is a required field."></
asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 138px">
Password:</td>
<td style="width: 214px">
<asp:TextBox
ID="PwdTextBox" runat="server" TextMode="Password"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator3"
runat="server" ControlToValidate="PwdTextBox"
Display="Dynamic"
ErrorMessage="Password is a required field."></
asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 138px;
height: 26px;">
Confirm Password:</td>
<td style="width: 214px;
height: 26px;">
<asp:TextBox
ID="ConfirmPwdTextBox" runat="server" TextMode="Password"></
asp:TextBox><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator8"
runat="server" ControlToValidate="ConfirmPwdTextBox"
Display="Dynamic"
ErrorMessage="Confirm Password is a required field."></
asp:RequiredFieldValidator><br />
<asp:CompareValidator
ID="CompareValidator1" runat="server" ControlToCompare="PwdTextBox"
ControlToValidate="ConfirmPwdTextBox" Display="Dynamic"
ErrorMessage="Password and Confirm Password do not match."></
asp:CompareValidator></td>
</tr>
</table>
</asp
anel>
</td>
</tr>
<tr>
<td style="width: 703px">
<asp
anel ID="InsertDealerAddressPanel" runat="server"
GroupingText="Address" Width="700px">
<table id="InsertDealerAddressTable" runat="server"
style="width: 672px">
<tr>
<td style="width: 125px">
Address:</td>
<td style="width: 214px">
<asp:TextBox ID="Address1TextBox" runat="server" Text='<%#
Bind("Address1") %>' Width="300px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7"
runat="server" ControlToValidate="Address1TextBox"
Display="Dynamic" ErrorMessage="Address is required."
ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 125px; height: 26px;">
</td>
<td style="width: 214px; height: 26px;">
<asp:TextBox ID="Address2TextBox" runat="server" Text='<%#
Bind("Address2") %>' Width="300px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 125px">
City:</td>
<td style="width: 214px">
<asp:TextBox ID="CityTextBox" runat="server" Text='<%#
Bind("City") %>' Width="176px" MaxLength="25"></asp:TextBox><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator11"
runat="server" ControlToValidate="CityTextBox"
Display="Dynamic" ErrorMessage="City is required."
ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 125px; height: 26px;">
State/Province:</td>
<td style="width: 214px; height: 26px;">
<asp
ropDownList ID="StateDropDown" runat="server"
DataSourceID="SqlDataSource1" DataTextField="description"
DataValueField="state" Width="176px">
<asp:ListItem
Selected="True"></asp:ListItem>
</asp
ropDownList><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator10"
runat="server" ControlToValidate="StateDropDown"
Display="Dynamic" ErrorMessage="Please choose a state."
ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 125px; height: 45px;">
Postal Code:</td>
<td style="width: 214px; height: 45px;">
<asp:TextBox ID="PostalCodeTextBox" runat="server" Text='<
%# Bind("PostalCode") %>' Width="176px" MaxLength="10"></
asp:TextBox><br />
<asp:RequiredFieldValidator
ID="RequiredFieldValidator9" runat="server"
ControlToValidate="PostalCodeTextBox" Display="Dynamic"
ErrorMessage="Postal Code is required."
ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 125px">
Country:</td>
<td style="width: 214px">
<asp
ropDownList ID="CountryDropDown" runat="server"
Width="176px">
<asp:ListItem Selected="True"></asp:ListItem>
<asp:ListItem>United States</asp:ListItem>
<asp:ListItem>Canada</asp:ListItem>
</asp
ropDownList>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator12"
runat="server" ControlToValidate="CountryDropDown"
Display="Dynamic" ErrorMessage="Please choose a Country."
ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
</table>
</asp
anel>
</td>
</tr>
<tr>
<td style="width: 703px">
<asp
anel ID="InsertDealerAccountPanel" runat="server"
GroupingText="Bank Account" Width="700px">
<table id="InsertDealerAccountTable" runat="server"
style="width: 672px">
<tr>
<td style="width: 125px">
Account Number:</td>
<td style="width: 214px">
<asp:TextBox ID="AccountTextBox" runat="server"
Text='<%# Bind("Account") %>' Width="300px"
MaxLength="20"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator15"
runat="server" ControlToValidate="AccountTextBox"
Display="Dynamic" ErrorMessage="Account Number is
required." ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 125px">
Routing Number:</td>
<td style="width: 214px">
<asp:TextBox ID="RoutingNumberTextBox" runat="server"
Text='<%# Eval("RoutingNumber") %>' Width="176px" MaxLength="9"></
asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator16"
runat="server" ControlToValidate="RoutingNumberTextBox"
Display="Dynamic" ErrorMessage="Routing Number is
required." ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 125px">
Account Currency:</td>
<td style="width: 214px">
<asp
ropDownList ID="CurrencyDropDown" runat="server"
Width="96px">
<asp:ListItem Selected="True"></asp:ListItem>
<asp:ListItem>USD</asp:ListItem>
<asp:ListItem>CND</asp:ListItem>
</asp
ropDownList><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator17"
runat="server" ControlToValidate="CurrencyDropDown"
Display="Dynamic" ErrorMessage="Please select a currency
for the account." Width="288px" ValidationGroup="Insert"></
asp:RequiredFieldValidator></td>
</tr>
</table>
</asp
anel>
</td>
</tr>
<tr>
<td style="width: 703px">
<asp
anel ID="InsertDealerAdvancedPanel" runat="server"
GroupingText="Advanced" Width="700px">
<table id="InsertDealerAdvancedTable" runat="server"
style="width: 672px">
<tr>
<td style="width: 90px">
Salesman Level:</td>
<td style="width: 218px">
<asp
ropDownList ID="SalesmanLevelDropDown"
runat="server" Width="96px">
<asp:ListItem>Level 1</asp:ListItem>
<asp:ListItem>Level 2</asp:ListItem>
</asp
ropDownList></td>
</tr>
<tr>
<td style="width: 90px">
Territory Manager:</td>
<td style="width: 218px">
<asp
ropDownList ID="TerritoryMgrDropDown" runat="server"
DataSourceID="TMObjectDataSource" DataTextField="Name"
DataValueField="SalesmanID" Width="176px"
AutoPostBack="True">
</asp
ropDownList><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator14"
runat="server" ControlToValidate="TerritoryMgrDropDown"
Display="Dynamic" ErrorMessage="Please choose a TM."
ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
</table>
</asp
anel>
</td>
</tr>
</table>
</InsertItemTemplate>
Code behind:
Protected Sub ModalOkButton_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ModalOkButton.Click
Try
With Me.FormView1
.ChangeMode(FormViewMode.Insert)
.Visible = True
End With
With Me.TextBox1
.Text = ""
.Visible = False
End With
Me.SearchButton.Visible = False
Me.lnkInsertTop.Visible = True
Me.lnkInsertBottom.Visible = True
Me.lnkEditTop.Visible = False
Me.lnkEditBottom.Visible = False
Me.lnkUpdateTop.Visible = False
Me.lnkUpdateBottom.Visible = False
Me.lnkCancelTop.Visible = True
Me.lnkCancelBottom.Visible = True
Dim TMDropDown As DropDownList
TMDropDown =
Me.FormView1.FindControl("TerritoryMgrDropDown")
If UserInfo.IsInRole("TM") Then
TMDropDown.SelectedValue =
UserInfo.Profile.GetPropertyValue("SalesmanID")
Else
TMDropDown.Visible = True
End If
Trace.Write(TMDropDown.Visible.ToString)
Trace.Write(TMDropDown.SelectedValue.ToString)
Catch ex As Exception
Throw ex
End Try
End Sub
Thanks,
Hollywood
panel) and I want to set the visible property to False when the user
is in a particular role. I'm using a modal popup button click event
to fire the change, and I set the formview mode to Insert and that
works great. Just after that I try to set the dropdownlist.visible =
false (or true depending) and I can find the control okay but it never
sets the visibility.
I've been chasing after this for a couple of days and any help would
really be appreciated!!
Here's the code:
aspx page:
<asp:FormView ID="FormView1" runat="server" DataSourceID="Dealer"
Width="27%">
<InsertItemTemplate>
<table id="InsertItemTable" runat="server" style="width: 656px">
<tr>
<td style="width: 703px">
<asp
GroupingText="Dealer Info" Width="700px">
<table id="InsertDealerInfoTable" runat="server"
style="width: 672px">
<tr>
<td style="width: 138px">
OGC ID:
</td>
<td style="width: 214px">
<asp:Label ID="OGCIDLabel" runat="server" Text='New'></
asp:Label>
</td>
</tr>
<tr>
<td style="width: 138px">
Contact Name:</td>
<td style="width: 214px">
<asp:TextBox ID="NameTextBox" runat="server" Text='<%#
Bind("Name") %>' Width="300px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="NameTextBox"
Display="Dynamic" ErrorMessage="Contact Name is reqired."
ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 138px">
Company Name:</td>
<td style="width: 214px">
<asp:TextBox ID="CompanyTextBox" runat="server" Text='<%#
Bind("Company") %>' Width="300px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 138px">
Company Type:</td>
<td style="width: 214px">
<asp:RadioButton ID="CorporationRadioBtn" runat="server"
GroupName="BusinessType" Text="Corporation" />
<asp:RadioButton ID="NonCorporationRadioBtn"
runat="server" GroupName="BusinessType" Text="Non-Corporate Entity" /
<asp:TextBox ID="Is1099TextBox" runat="server" Text='<%#
Eval("Is_1099") %>' Visible="False"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 138px; height: 26px;">
Phone:</td>
<td style="width: 214px; height: 26px;">
<asp:TextBox ID="PhoneTextBox" runat="server" Text='<%#
Bind("Phone") %>' Width="152px" MaxLength="10"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator4"
runat="server" ControlToValidate="PhoneTextBox"
Display="Dynamic" ErrorMessage="Phone is required."
ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 138px">
Fax:</td>
<td style="width: 214px">
<asp:TextBox ID="FaxTextBox" runat="server" Text='<%#
Eval("FaxNumber") %>' Width="152px" MaxLength="10"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 138px">
Cell Phone:</td>
<td style="width: 214px">
<asp:TextBox ID="CellPhoneTextBox" runat="server" Text='<
%# Eval("CellPhone") %>' Width="152px" MaxLength="10"></asp:TextBox></
td>
</tr>
<tr>
<td style="width: 138px">
Email Address:</td>
<td style="width: 214px">
<asp:TextBox ID="EmailTextBox" runat="server" Text='<%#
Eval("EmailAddress") %>' Width="300px"></asp:TextBox><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator5"
runat="server" ControlToValidate="EmailTextBox"
Display="Dynamic" ErrorMessage="Email Address is
required." ValidationGroup="Insert"></
asp:RequiredFieldValidator><asp:RegularExpressionValidator
ID="RegularExpressionValidator1" runat="server"
ControlToValidate="EmailTextBox"
Display="Dynamic" ErrorMessage="You must enter a valid
email address." Width="296px" ValidationExpression="\w+([-+.']\w+)*@\w+
([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td style="width: 138px">
Tax ID or Social Security:</td>
<td style="width: 214px">
<asp:TextBox ID="TaxIDTextBox" runat="server" Text='<%#
Eval("TaxID") %>' Width="152px" MaxLength="9"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator6"
runat="server" ControlToValidate="TaxIDTextBox"
Display="Dynamic" ErrorMessage="Please enter a valid
Federal Tax ID or SS Number." ValidationGroup="Insert" Width="376px"></
asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 138px;
height: 26px">
User ID:</td>
<td style="width: 214px;
height: 26px">
<asp:TextBox
ID="UserIDTextBox" runat="server"></asp:TextBox><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
runat="server" ControlToValidate="UserIDTextBox"
Display="Dynamic"
ErrorMessage="User ID is a required field."></
asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 138px">
Password:</td>
<td style="width: 214px">
<asp:TextBox
ID="PwdTextBox" runat="server" TextMode="Password"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator3"
runat="server" ControlToValidate="PwdTextBox"
Display="Dynamic"
ErrorMessage="Password is a required field."></
asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 138px;
height: 26px;">
Confirm Password:</td>
<td style="width: 214px;
height: 26px;">
<asp:TextBox
ID="ConfirmPwdTextBox" runat="server" TextMode="Password"></
asp:TextBox><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator8"
runat="server" ControlToValidate="ConfirmPwdTextBox"
Display="Dynamic"
ErrorMessage="Confirm Password is a required field."></
asp:RequiredFieldValidator><br />
<asp:CompareValidator
ID="CompareValidator1" runat="server" ControlToCompare="PwdTextBox"
ControlToValidate="ConfirmPwdTextBox" Display="Dynamic"
ErrorMessage="Password and Confirm Password do not match."></
asp:CompareValidator></td>
</tr>
</table>
</asp
</td>
</tr>
<tr>
<td style="width: 703px">
<asp
GroupingText="Address" Width="700px">
<table id="InsertDealerAddressTable" runat="server"
style="width: 672px">
<tr>
<td style="width: 125px">
Address:</td>
<td style="width: 214px">
<asp:TextBox ID="Address1TextBox" runat="server" Text='<%#
Bind("Address1") %>' Width="300px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7"
runat="server" ControlToValidate="Address1TextBox"
Display="Dynamic" ErrorMessage="Address is required."
ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 125px; height: 26px;">
</td>
<td style="width: 214px; height: 26px;">
<asp:TextBox ID="Address2TextBox" runat="server" Text='<%#
Bind("Address2") %>' Width="300px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 125px">
City:</td>
<td style="width: 214px">
<asp:TextBox ID="CityTextBox" runat="server" Text='<%#
Bind("City") %>' Width="176px" MaxLength="25"></asp:TextBox><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator11"
runat="server" ControlToValidate="CityTextBox"
Display="Dynamic" ErrorMessage="City is required."
ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 125px; height: 26px;">
State/Province:</td>
<td style="width: 214px; height: 26px;">
<asp
DataSourceID="SqlDataSource1" DataTextField="description"
DataValueField="state" Width="176px">
<asp:ListItem
Selected="True"></asp:ListItem>
</asp
<asp:RequiredFieldValidator ID="RequiredFieldValidator10"
runat="server" ControlToValidate="StateDropDown"
Display="Dynamic" ErrorMessage="Please choose a state."
ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 125px; height: 45px;">
Postal Code:</td>
<td style="width: 214px; height: 45px;">
<asp:TextBox ID="PostalCodeTextBox" runat="server" Text='<
%# Bind("PostalCode") %>' Width="176px" MaxLength="10"></
asp:TextBox><br />
<asp:RequiredFieldValidator
ID="RequiredFieldValidator9" runat="server"
ControlToValidate="PostalCodeTextBox" Display="Dynamic"
ErrorMessage="Postal Code is required."
ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 125px">
Country:</td>
<td style="width: 214px">
<asp
Width="176px">
<asp:ListItem Selected="True"></asp:ListItem>
<asp:ListItem>United States</asp:ListItem>
<asp:ListItem>Canada</asp:ListItem>
</asp
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator12"
runat="server" ControlToValidate="CountryDropDown"
Display="Dynamic" ErrorMessage="Please choose a Country."
ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
</table>
</asp
</td>
</tr>
<tr>
<td style="width: 703px">
<asp
GroupingText="Bank Account" Width="700px">
<table id="InsertDealerAccountTable" runat="server"
style="width: 672px">
<tr>
<td style="width: 125px">
Account Number:</td>
<td style="width: 214px">
<asp:TextBox ID="AccountTextBox" runat="server"
Text='<%# Bind("Account") %>' Width="300px"
MaxLength="20"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator15"
runat="server" ControlToValidate="AccountTextBox"
Display="Dynamic" ErrorMessage="Account Number is
required." ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 125px">
Routing Number:</td>
<td style="width: 214px">
<asp:TextBox ID="RoutingNumberTextBox" runat="server"
Text='<%# Eval("RoutingNumber") %>' Width="176px" MaxLength="9"></
asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator16"
runat="server" ControlToValidate="RoutingNumberTextBox"
Display="Dynamic" ErrorMessage="Routing Number is
required." ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 125px">
Account Currency:</td>
<td style="width: 214px">
<asp
Width="96px">
<asp:ListItem Selected="True"></asp:ListItem>
<asp:ListItem>USD</asp:ListItem>
<asp:ListItem>CND</asp:ListItem>
</asp
<asp:RequiredFieldValidator ID="RequiredFieldValidator17"
runat="server" ControlToValidate="CurrencyDropDown"
Display="Dynamic" ErrorMessage="Please select a currency
for the account." Width="288px" ValidationGroup="Insert"></
asp:RequiredFieldValidator></td>
</tr>
</table>
</asp
</td>
</tr>
<tr>
<td style="width: 703px">
<asp
GroupingText="Advanced" Width="700px">
<table id="InsertDealerAdvancedTable" runat="server"
style="width: 672px">
<tr>
<td style="width: 90px">
Salesman Level:</td>
<td style="width: 218px">
<asp
runat="server" Width="96px">
<asp:ListItem>Level 1</asp:ListItem>
<asp:ListItem>Level 2</asp:ListItem>
</asp
</tr>
<tr>
<td style="width: 90px">
Territory Manager:</td>
<td style="width: 218px">
<asp
DataSourceID="TMObjectDataSource" DataTextField="Name"
DataValueField="SalesmanID" Width="176px"
AutoPostBack="True">
</asp
<asp:RequiredFieldValidator ID="RequiredFieldValidator14"
runat="server" ControlToValidate="TerritoryMgrDropDown"
Display="Dynamic" ErrorMessage="Please choose a TM."
ValidationGroup="Insert"></asp:RequiredFieldValidator></td>
</tr>
</table>
</asp
</td>
</tr>
</table>
</InsertItemTemplate>
Code behind:
Protected Sub ModalOkButton_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ModalOkButton.Click
Try
With Me.FormView1
.ChangeMode(FormViewMode.Insert)
.Visible = True
End With
With Me.TextBox1
.Text = ""
.Visible = False
End With
Me.SearchButton.Visible = False
Me.lnkInsertTop.Visible = True
Me.lnkInsertBottom.Visible = True
Me.lnkEditTop.Visible = False
Me.lnkEditBottom.Visible = False
Me.lnkUpdateTop.Visible = False
Me.lnkUpdateBottom.Visible = False
Me.lnkCancelTop.Visible = True
Me.lnkCancelBottom.Visible = True
Dim TMDropDown As DropDownList
TMDropDown =
Me.FormView1.FindControl("TerritoryMgrDropDown")
If UserInfo.IsInRole("TM") Then
TMDropDown.SelectedValue =
UserInfo.Profile.GetPropertyValue("SalesmanID")
Else
TMDropDown.Visible = True
End If
Trace.Write(TMDropDown.Visible.ToString)
Trace.Write(TMDropDown.SelectedValue.ToString)
Catch ex As Exception
Throw ex
End Try
End Sub
Thanks,
Hollywood