FormView Radio button list and disabled textboxes issue

Hi,
in FormView1 have Radio button list with two items in list (two radio buttons with values V and F).Default FormView mode is read only but I also use update and insert modes. I want to disable few text boxes in FormView depending on value of radio button list and I want that to work in all FormView modes. This is my code behind but when I step through code on this line
If fizvi.SelectedValue = "V" Then
got message
Object reference not set to an instance of an object.
How can I make this work?
Thanks
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim fizvi As RadioButtonList
        Dim ilotext As TextBox
        fizvi = FormView1.FindControl("RadioButtonList2")
        ilotext = FormView1.FindControl("TextBox25")
        If fizvi.SelectedValue = "V" Then
            ilotext.Enabled = False
        Else
            ilotext.Enabled = True
        End If
    End Sub

Open in new window

LVL 1
kahvedzicAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David H.H.LeeCommented:
Hi kahvedzic,
>>Object reference not set to an instance of an object.
Could be looking wrong control - RadioButtonList2? Please post your HTML design code for further inspection
0
kahvedzicAuthor Commented:
here is html design code of this page.
It might be problem that I do not load FormView on page load. Then I add this code to FormView1_Load event and it looks like this:

Protected Sub FormView1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.Load
        Dim fizvi As RadioButtonList
        Dim ilotext As TextBox
        fizvi = FormView1.FindControl("RadioButtonList2")
        ilotext = FormView1.FindControl("TextBox25")
        If fizvi.SelectedValue = "V" Then
            ilotext.Enabled = False
        Else
            ilotext.Enabled = True
        End If
    End Sub

But I still have same error message: Object reference not set to an instance of an object.


Here is my complete code behind


Partial Class _Default
    Inherits System.Web.UI.Page
    Dim uslov As String

    Protected Sub AdvancedButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AdvancedButton.Click
        If Asset_No_Label.Visible = False And Location_Label.Visible = False And OS_Label.Visible = False And Serial_Label.Visible = False And Asset_No_SearchBox.Visible = False And Location_SearchBox.Visible = False And OS_SearchBox.Visible = False And Serial_SearchBox.Visible = False Then
            Asset_No_Label.Visible = True
            Location_Label.Visible = True
            OS_Label.Visible = True
            Serial_Label.Visible = True
            Asset_No_SearchBox.Visible = True
            Location_SearchBox.Visible = True
            OS_SearchBox.Visible = True
            Serial_SearchBox.Visible = True
        Else
            Asset_No_Label.Visible = False
            Location_Label.Visible = False
            OS_Label.Visible = False
            Serial_Label.Visible = False
            Asset_No_SearchBox.Visible = False
            Location_SearchBox.Visible = False
            OS_SearchBox.Visible = False
            Serial_SearchBox.Visible = False
        End If

        If Asset_No_Label.Visible = True Then
            AdvancedButton.Text = "Skloni"
        Else
            AdvancedButton.Text = "Prosirena pretraga"
        End If
    End Sub

    Protected Sub serveri_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles serveri.Click
        Dim connectionString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
        Dim mySqlConnection As New Data.SqlClient.SqlConnection(connectionString)
        Dim cmd As New Data.SqlClient.SqlCommand
        Dim dreader As Data.SqlClient.SqlDataReader
        If mySqlConnection.State = Data.ConnectionState.Open Then mySqlConnection.Close()
        mySqlConnection.Open()

        cmd.Connection = mySqlConnection
        cmd.CommandText = "SELECT Name from Servers with (nolock) order by name;"

        dreader = cmd.ExecuteReader
        If dreader.HasRows Then
            ListBox1.Items.Clear()
            Do While dreader.Read()
                ListBox1.Items.Add(dreader.Item("Name"))
            Loop
            ListBox1.Visible = True
        End If
        dreader.Close()

        mySqlConnection.Close()

        Name_SearchBox.Text = ""
        Asset_No_SearchBox.Text = ""
        Location_SearchBox.Text = ""
        OS_SearchBox.Text = ""
        Label1.Text = ""

    End Sub

    Protected Sub TraziButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TraziButton.Click
        Dim connectionString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
        Dim mySqlConnection As New Data.SqlClient.SqlConnection(connectionString)
        Dim cmd As New Data.SqlClient.SqlCommand
        Dim dreader As Data.SqlClient.SqlDataReader
        If mySqlConnection.State = Data.ConnectionState.Open Then mySqlConnection.Close()
        mySqlConnection.Open()

        Formiraj_Uslov()
        If uslov <> "" Then
            Label1.Text = ""
            cmd.Connection = mySqlConnection
            cmd.CommandText = "SELECT Name from Servers with (nolock) where (" + uslov + ") order by name;"

            cmd.Parameters.AddWithValue("@Name", Name_SearchBox.Text)
            cmd.Parameters.AddWithValue("@Asset_Number", Asset_No_SearchBox.Text)
            cmd.Parameters.AddWithValue("@Location", Location_SearchBox.Text)
            cmd.Parameters.AddWithValue("@OS", OS_SearchBox.Text)
            cmd.Parameters.AddWithValue("@Serial_Number", Serial_SearchBox.Text)

            dreader = cmd.ExecuteReader
            If dreader.HasRows Then
                ListBox1.Items.Clear()
                Do While dreader.Read()
                    ListBox1.Items.Add(dreader.Item("Name"))
                Loop

                ListBox1.Visible = True
            Else
                ListBox1.Items.Clear()
                ListBox1.Visible = False
                Label1.Text = "Nisu pronadjeni rezultati koji zadovoljavaju zadane kriterije."
                Label1.Visible = True
            End If

            dreader.Close()

        Else
            ListBox1.Items.Clear()
            ListBox1.Visible = False
            Label1.Text = "Unesite kriterije za pretragu."
            Label1.Visible = True
        End If

        mySqlConnection.Close()
    End Sub

    Protected Sub NoviButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles NoviButton.Click
        FormView1.ChangeMode(FormViewMode.Insert)
        ListBox1.ClearSelection()
        ListBox1.Visible = False
        Name_SearchBox.Text = ""
        Asset_No_SearchBox.Text = ""
        Location_SearchBox.Text = ""
        OS_SearchBox.Text = ""
        Label1.Text = ""
    End Sub

    Protected Sub NewButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        ListBox1.ClearSelection()
        ListBox1.Visible = False
        Name_SearchBox.Text = ""
        Asset_No_SearchBox.Text = ""
        Location_SearchBox.Text = ""
        OS_SearchBox.Text = ""
        Label1.Text = ""
    End Sub

    Private Sub Formiraj_Uslov()
        If Name_SearchBox.Text <> "" Then
            uslov = "Name like '%'+@Name+'%'"
        Else
            uslov = ""
        End If

        If Asset_No_SearchBox.Text <> "" Then
            If uslov = "" Then
                uslov = "Asset_Number like '%'+@Asset_Number+'%'"
            Else
                uslov = uslov + " and Asset_Number like '%'+@Asset_Number +'%'"
            End If
        End If

        If Location_SearchBox.Text <> "" Then
            If uslov = "" Then
                uslov = "Location like '%'+@Location+'%'"
            Else
                uslov = uslov + " and Location like '%'+@Location+'%'"
            End If
        End If

        If OS_SearchBox.Text <> "" Then
            If uslov = "" Then
                uslov = "OS like '%'+@OS+'%'"
            Else
                uslov = uslov + " and OS like '%'+@OS+'%'"
            End If
        End If

        If Serial_SearchBox.Text <> "" Then
            If uslov = "" Then
                uslov = "Serial_Number like '%'+@Serial_Number+'%'"
            Else
                uslov = uslov + " and Serial_Number like '%'+@Serial_Number+'%'"
            End If
        End If
    End Sub

    Protected Sub Details_Button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Details_Button.Click
        FormView1.ChangeMode(FormViewMode.ReadOnly)
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Name_SearchBox.Focus()
       
    End Sub

    Protected Sub InsertButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim namebox As TextBox
        namebox = FormView1.FindControl("NameTextBox")

        If namebox.Text = "" Then
            Response.Write("<script>language='javascript'>alert('Insert Name');</script>")
        End If
    End Sub

    Protected Sub FormView1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.Load
        Dim fizvi As RadioButtonList
        Dim ilotext As TextBox
        fizvi = FormView1.FindControl("RadioButtonList2")
        ilotext = FormView1.FindControl("TextBox25")
        If fizvi.SelectedValue = "V" Then
            ilotext.Enabled = False
        Else
            ilotext.Enabled = True
        End If
    End Sub
End Class

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Servers</title>
</head>
<body>

    <form id="form1" runat="server" >
    <div>
        &nbsp;
        <asp:Button ID="Details_Button" runat="server" Height="26px" Text="Detalji" Width="60px" />
        &nbsp;&nbsp;&nbsp;<asp:Button ID="NoviButton" runat="server" Height="26px" Text="Novi" Width="60px" />
        &nbsp;&nbsp;
        <asp:Button ID="serveri" runat="server" Height="26px" Text="Pregled svih servera" Width="136px" /><br />
        <br />
        <asp:Panel ID="Panel1" runat="server" BorderStyle="Groove" Width="1130px">
        <table>
            <tr>
                <td style="width: 65px">
                        <asp:Label ID="Name_Label" runat="server" Font-Names="Verdana" Font-Size="10pt" Text="Name:"></asp:Label></td>
                <td style="width: 100px">
                        <asp:TextBox ID="Name_SearchBox" runat="server"></asp:TextBox></td>
                <td style="width: 100px">
                        <asp:Label ID="Asset_No_Label" runat="server" Font-Names="Verdana" Font-Size="10pt"
                            Text="Asset No:" Visible="False"></asp:Label></td>
                <td style="width: 100px">
                        <asp:TextBox ID="Asset_No_SearchBox" runat="server" Visible="False"></asp:TextBox></td>
                <td style="width: 82px">
                        <asp:Label ID="Location_Label" runat="server" Font-Names="Verdana" Font-Size="10pt"
                            Text="Location:" Visible="False"></asp:Label></td>
                <td style="width: 100px">
                        <asp:TextBox ID="Location_SearchBox" runat="server" Visible="False"></asp:TextBox></td>
                <td style="width: 32px">
                        <asp:Label ID="OS_Label" runat="server" Font-Names="Verdana" Font-Size="10pt"
                            Text="OS:" Visible="False"></asp:Label></td>
                <td style="width: 100px">
                        <asp:TextBox ID="OS_SearchBox" runat="server" Visible="False"></asp:TextBox></td>
                <td style="width: 100px">
                    <asp:Label ID="Serial_Label" runat="server" Font-Names="Verdana" Font-Size="10pt"
                        Text="Serial No:" Visible="False"></asp:Label></td>
                <td style="width: 100px">
                    <asp:TextBox ID="Serial_SearchBox" runat="server" Visible="False"></asp:TextBox></td>
            </tr>
            <tr>
                <td colspan="12" style="height: 5px">
                </td>
            </tr>
            <tr>
                <td style="width: 65px">
                        <asp:Button ID="TraziButton" runat="server" Height="26px" Text="Trazi" Width="60px" />
                </td>
                <td style="width: 100px">
                        <asp:Button
            ID="AdvancedButton" runat="server" Text="Prosirena pretraga" Height="26px" Width="140px" Font-Names="Verdana" Font-Size="10pt" /></td>
                <td colspan="10">
                    <asp:Label ID="Label1" runat="server" Text="Label" Font-Names="Verdana" Font-Size="Small" Visible="False" ForeColor="Red"></asp:Label>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="Name_SearchBox"
                        Display="Dynamic" ErrorMessage="Unos karaktera 'space' nije dozvoljen u polju 'Name'"
                        Font-Names="Verdana" Font-Size="Small" ValidationExpression="^\w[a-zA-Z@#0-9.]*$">Unos karaktera 'space' nije dozvoljen u polju 'Name'</asp:RegularExpressionValidator></td>
            </tr>
        </table>
        </asp:Panel>
        <br />
        <table>
            <tr>
                <td style="width: 100px; height: 472px;" align="center">
                    <asp:ListBox ID="ListBox1" runat="server" Font-Names="Verdana" Font-Size="10pt" Height="493px" Visible="False" Width="205px"></asp:ListBox>
                </td>
                <td style="width: 852px; height: 472px;">
                    <asp:FormView ID="FormView1" runat="server" BackColor="White" BorderColor="#DEDFDE"
                        BorderStyle="None" BorderWidth="1px" CellPadding="4" DataKeyNames="ID" DataSourceID="servers_form"
                        ForeColor="Black" GridLines="Vertical" Height="348px" Width="918px">
                        <FooterStyle BackColor="#CCCC99" />
                        <RowStyle BackColor="#F7F7DE" />
                        <EditItemTemplate>
                            <table style="font-size: 10pt; font-family: Verdana">
                                <tr>
                                    <td colspan="6" style="text-align: center">
                                        ID
                                        <asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>'></asp:Label>
                                        <asp:RadioButtonList ID="RadioButtonList3" runat="server" RepeatDirection="Horizontal"
                                            SelectedValue='<%# Bind("FV") %>'>
                                            <asp:ListItem Value="F">Physical</asp:ListItem>
                                            <asp:ListItem Value="V">Virtual</asp:ListItem>
                                        </asp:RadioButtonList></td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        Name</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 119px">
                                        HW Model</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_ModelTextBox" runat="server" Text='<%# Bind("HW_Model") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 184px">
                                        Serial Number</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Serial_Number") %>'></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        OS</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="OSTextBox" runat="server" Text='<%# Bind("OS") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 119px">
                                        HW CPU</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_CPUTextBox" runat="server" Text='<%# Bind("HW_CPU") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 184px">
                                        Part Number</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="Part_NumberTextBox" runat="server" Text='<%# Bind("Part_Number") %>'>
                            </asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        OS Level</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="OS_LevelTextBox" runat="server" Text='<%# Bind("OS_Level") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 119px">
                                        HW Memory</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_MemoryTextBox" runat="server" Text='<%# Bind("HW_Memory") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 184px">
                                        Install Date</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="Installed_DateTextBox" runat="server" Text='<%# Bind("Installed_Date") %>'>
                            </asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        IP Address</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="IP_AddressTextBox" runat="server" Text='<%# Bind("IP_Address") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 119px">
                                        HW Array ctl</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_Array_ctlTextBox" runat="server" Text='<%# Bind("HW_Array_ctl") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 184px">
                                        Warranty Date</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="Warranty_DateTextBox" runat="server" Text='<%# Bind("Warranty_Date") %>'></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        ILO Address</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="ILO_AddressTextBox" runat="server" Text='<%# Bind("ILO_Address") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 119px">
                                        HW HDD</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_HDD1TextBox" runat="server" Text='<%# Bind("HW_HDD1") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 184px">
                                        Support Contact Name</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="Support_Contact_NameTextBox" runat="server" Text='<%# Bind("Support_Contact_Name") %>'>
                            </asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        Asset Number</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="Asset_NumberTextBox" runat="server" Text='<%# Bind("Asset_Number") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 119px">
                                        HW RAID Level</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_RAID_LevelTextBox" runat="server" Text='<%# Bind("HW_RAID_Level") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 184px">
                                        Owner</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="OwnerTextBox" runat="server" Text='<%# Bind("Owner") %>'>
                            </asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        SystemID</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="SystemIDTextBox" runat="server" Text='<%# Bind("SystemID") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 119px">
                                        HW HDD Type</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_HDD_typeTextBox" runat="server" Text='<%# Bind("HW_HDD_type") %>'>
                            </asp:TextBox></td>
                                    <td colspan="2">
                                        </td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        Location</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="LocationTextBox" runat="server" Text='<%# Bind("Location") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 119px">
                                        HW Storage</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_StorageTextBox" runat="server" Text='<%# Bind("HW_Storage") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 184px">
                                    </td>
                                    <td style="width: 100px">
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        Rack Number</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="Rack_NumberTextBox" runat="server" Text='<%# Bind("Rack_Number") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 119px">
                                        HW RAID LES</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_RAID_LESTextBox" runat="server" Text='<%# Bind("HW_RAID_LES") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 184px">
                                    </td>
                                    <td style="width: 100px">
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        HW Other</td>
                                    <td colspan="5">
                                        <asp:TextBox ID="HW_OtherTextBox" runat="server" Text='<%# Bind("HW_Other") %>' Height="80px" TextMode="MultiLine" Width="435px"></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        Services</td>
                                    <td colspan="5">
                                        <asp:TextBox ID="ServicesTextBox" runat="server" Text='<%# Bind("Services") %>' Height="80px" Width="435px"></asp:TextBox></td>
                                </tr>
                            </table>
                            <br />
                            <table style="font-size: 10pt; font-family: Verdana">
                                <tr>
                                    <td align="right" style="width: 234px">
                                        <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"  OnClientClick="return confirm('Jeste li sigurni da zelite obrisati ovaj slog?');" 
                                            Height="26px" Text="Izmijeni" Width="60px" /></td>
                                    <td style="width: 234px">
                                        <asp:Button ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                                            Height="26px" Text="Ponisti" Width="60px" /></td>
                                </tr>
                            </table>
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <table style="font-size: 10pt; font-family: Verdana">
                                <tr>
                                    <td colspan="6" style="text-align: center">
                                        <asp:RadioButtonList ID="RadioButtonList1" runat="server" SelectedValue='<%# Bind("FV") %>'
                                            Width="84px" RepeatColumns="2">
                                            <asp:ListItem Value="F">Physical</asp:ListItem>
                                            <asp:ListItem Value="V">Virtual</asp:ListItem>
                                        </asp:RadioButtonList></td>
                                </tr>
                                <tr>
                                    <td style="width: 105px">
                                        Name</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 115px">
                                        HW Model</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_ModelTextBox" runat="server" Text='<%# Bind("HW_Model") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 159px">
                                        Serial Number</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Serial_Number") %>'></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 105px">
                                        OS</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="OSTextBox" runat="server" Text='<%# Bind("OS") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 115px">
                                        HW CPU</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_CPUTextBox" runat="server" Text='<%# Bind("HW_CPU") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 159px">
                                        Part Number</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="Part_NumberTextBox" runat="server" Text='<%# Bind("Part_Number") %>'>
                            </asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 105px">
                                        OS Level</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="OS_LevelTextBox" runat="server" Text='<%# Bind("OS_Level") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 115px">
                                        HW Memory</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_MemoryTextBox" runat="server" Text='<%# Bind("HW_Memory") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 159px">
                                        Install Date</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="Installed_DateTextBox" runat="server" Text='<%# Bind("Installed_Date") %>'>
                            </asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 105px">
                                        IP Address</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="IP_AddressTextBox" runat="server" Text='<%# Bind("IP_Address") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 115px">
                                        HW Array ctl</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_Array_ctlTextBox" runat="server" Text='<%# Bind("HW_Array_ctl") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 159px">
                                        Warranty Date</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="Warranty_DateTextBox" runat="server" Text='<%# Bind("Warranty_Date") %>'>
                            </asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 105px">
                                        ILO Address</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="ILO_AddressTextBox" runat="server" Text='<%# Bind("ILO_Address") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 115px">
                                        HW HDD</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_HDD1TextBox" runat="server" Text='<%# Bind("HW_HDD1") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 159px">
                                        Support Contact Name</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="Support_Contact_NameTextBox" runat="server" Text='<%# Bind("Support_Contact_Name") %>'>
                            </asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 105px">
                                        Asset Number</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="Asset_NumberTextBox" runat="server" Text='<%# Bind("Asset_Number") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 115px">
                                        HW RAID Level</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_RAID_LevelTextBox" runat="server" Text='<%# Bind("HW_RAID_Level") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 159px">
                                        Owner</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="OwnerTextBox" runat="server" Text='<%# Bind("Owner") %>'>
                            </asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 105px">
                                        SystemID</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="SystemIDTextBox" runat="server" Text='<%# Bind("SystemID") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 115px">
                                        HW HDD type</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_HDD_typeTextBox" runat="server" Text='<%# Bind("HW_HDD_type") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 159px">
                                    </td>
                                    <td style="width: 100px">
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 105px">
                                        Location</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="LocationTextBox" runat="server" Text='<%# Bind("Location") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 115px">
                                        HW Storage</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_StorageTextBox" runat="server" Text='<%# Bind("HW_Storage") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 159px">
                                    </td>
                                    <td style="width: 100px">
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 105px">
                                        Rack Number</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="Rack_NumberTextBox" runat="server" Text='<%# Bind("Rack_Number") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 115px">
                                        HW RAID LES</td>
                                    <td style="width: 100px">
                                        <asp:TextBox ID="HW_RAID_LESTextBox" runat="server" Text='<%# Bind("HW_RAID_LES") %>'>
                            </asp:TextBox></td>
                                    <td style="width: 159px">
                                    </td>
                                    <td style="width: 100px">
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 105px">
                                        HW Other</td>
                                    <td colspan="5">
                                        <asp:TextBox ID="HW_OtherTextBox" runat="server" Text='<%# Bind("HW_Other") %>' Height="80px" TextMode="MultiLine" Width="435px"></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 105px">
                                        Services</td>
                                    <td colspan="5">
                                        <asp:TextBox ID="ServicesTextBox" runat="server" Text='<%# Bind("Services") %>' Height="80px" TextMode="MultiLine" Width="435px"></asp:TextBox></td>
                                </tr>
                            </table>
                            <span style="font-size: 10pt; font-family: Verdana">&nbsp;</span><table style="font-size: 10pt; font-family: Verdana">
                                <tr>
                                    <td align="right" style="width: 234px">
                                        <asp:Button ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                                            Height="26px" Text="Upisi" Width="60px" OnClick="InsertButton_Click" /></td>
                                    <td style="width: 234px">
                                        <asp:Button ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                                            Height="26px" Text="Ponisti" Width="60px" /></td>
                                </tr>
                            </table>
                        </InsertItemTemplate>
                        <ItemTemplate>
                            <table style="font-size: 10pt; font-family: Verdana">
                                <tr>
                                    <td colspan="9" style="height: 21px; text-align: center">
                                        <asp:RadioButtonList ID="RadioButtonList2" runat="server" RepeatDirection="Horizontal"
                                            SelectedValue='<%# Bind("FV") %>' Width="84px">
                                            <asp:ListItem Value="F">Physical</asp:ListItem>
                                            <asp:ListItem Value="V">Virtual</asp:ListItem>
                                        </asp:RadioButtonList>ID
                                        <asp:Label ID="IDLabel" runat="server" Font-Bold="True" Text='<%# Bind("ID") %>'></asp:Label>
                                        &nbsp;
                                        &nbsp; &nbsp; &nbsp;&nbsp; System ID
                                        <asp:Label ID="SIDLabel" runat="server" Font-Bold="True"
                                            Text='<%# Bind("SystemID") %>'></asp:Label>
                                        &nbsp;
                                        &nbsp; &nbsp; &nbsp; Asset Number
                                        <asp:Label ID="ASNLabel" runat="server" Font-Bold="True"
                                            Text='<%# Bind("Asset_Number") %>'></asp:Label></td>
                                </tr>
                                <tr>
                                    <td style="width: 113px; height: 21px">
                                        Name</td>
                                    <td style="width: 151px; height: 21px">
                                        <asp:TextBox ID="TextBox2" runat="server" ReadOnly="True" Text='<%# Bind("Name") %>'></asp:TextBox></td>
                                    <td style="width: 160px; height: 21px">
                                        HW Model</td>
                                    <td style="width: 115px; height: 21px">
                                        <asp:TextBox ID="TextBox6" runat="server" ReadOnly="True" Text='<%# Bind("HW_Model") %>'></asp:TextBox></td>
                                    <td style="width: 166px; height: 21px">
                                        Serial Number</td>
                                    <td style="width: 91px; height: 21px">
                                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Serial_Number") %>'></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        OS</td>
                                    <td style="width: 151px">
                                        <asp:TextBox ID="TextBox18" runat="server" ReadOnly="True" Text='<%# Bind("OS") %>'></asp:TextBox></td>
                                    <td style="width: 160px">
                                        HW CPU</td>
                                    <td style="width: 115px">
                                        <asp:TextBox ID="TextBox7" runat="server" ReadOnly="True" Text='<%# Bind("HW_CPU") %>'></asp:TextBox></td>
                                    <td style="width: 166px">
                                        Part Number</td>
                                    <td style="width: 91px">
                                        <asp:TextBox ID="TextBox34" runat="server" ReadOnly="True" Text='<%# Bind("Part_Number") %>'></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        OS Level</td>
                                    <td style="width: 151px">
                                        <asp:TextBox ID="TextBox19" runat="server" ReadOnly="True" Text='<%# Bind("OS_Level") %>'></asp:TextBox></td>
                                    <td style="width: 160px">
                                        HW Memory</td>
                                    <td style="width: 115px">
                                        <asp:TextBox ID="TextBox9" runat="server" ReadOnly="True" Text='<%# Bind("HW_Memory") %>'></asp:TextBox></td>
                                    <td style="width: 166px">
                                        Install Date</td>
                                    <td style="width: 91px">
                                        <asp:TextBox ID="TextBox32" runat="server" ReadOnly="True" Text='<%# Bind("Installed_Date", "{0:d}") %>'></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        IP Address</td>
                                    <td style="width: 151px">
                                        <asp:TextBox ID="TextBox24" runat="server" ReadOnly="True" Text='<%# Bind("IP_Address") %>'></asp:TextBox></td>
                                    <td style="width: 160px">
                                        HW Array ctl</td>
                                    <td style="width: 115px">
                                        <asp:TextBox ID="TextBox16" runat="server" ReadOnly="True" Text='<%# Bind("HW_Array_ctl") %>'></asp:TextBox></td>
                                    <td style="width: 166px">
                                        Warranty Date</td>
                                    <td style="width: 91px">
                                        <asp:TextBox ID="TextBox31" runat="server" ReadOnly="True" Text='<%# Bind("Warranty_Date", "{0:d}") %>'></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        ILO Address</td>
                                    <td style="width: 151px">
                                        <asp:TextBox ID="TextBox25" runat="server" ReadOnly="True" Text='<%# Bind("ILO_Address") %>'></asp:TextBox></td>
                                    <td style="width: 160px">
                                        HW HDD</td>
                                    <td style="width: 115px">
                                        <asp:TextBox ID="TextBox10" runat="server" ReadOnly="True" Text='<%# Bind("HW_HDD1") %>'></asp:TextBox></td>
                                    <td style="width: 166px">
                                        Support Contact Name</td>
                                    <td style="width: 91px">
                                        <asp:TextBox ID="TextBox33" runat="server" ReadOnly="True" Text='<%# Bind("Support_Contact_Name") %>'></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        Location</td>
                                    <td style="width: 151px">
                                        <asp:TextBox ID="TextBox22" runat="server" ReadOnly="True" Text='<%# Bind("Location") %>'></asp:TextBox></td>
                                    <td style="width: 160px">
                                        HW RAID Level</td>
                                    <td style="width: 115px">
                                        <asp:TextBox ID="TextBox13" runat="server" ReadOnly="True" Text='<%# Bind("HW_RAID_Level") %>'></asp:TextBox></td>
                                    <td style="width: 166px">
                                        Owner</td>
                                    <td style="width: 91px">
                                        <asp:TextBox ID="TextBox29" runat="server" ReadOnly="True" Text='<%# Bind("Owner") %>'></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        Rack Number</td>
                                    <td style="width: 151px">
                                        <asp:TextBox ID="TextBox30" runat="server" ReadOnly="True" Text='<%# Bind("Rack_Number") %>'></asp:TextBox></td>
                                    <td style="width: 160px">
                                        HW HDD Type</td>
                                    <td style="width: 115px">
                                        <asp:TextBox ID="TextBox12" runat="server" ReadOnly="True" Text='<%# Bind("HW_HDD_type") %>'></asp:TextBox></td>
                                    <td style="width: 166px">
                                        </td>
                                    <td style="width: 91px">
                                        </td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        </td>
                                    <td style="width: 151px">
                                        </td>
                                    <td style="width: 160px">
                                        HW Storage</td>
                                    <td style="width: 115px">
                                        <asp:TextBox ID="TextBox15" runat="server" ReadOnly="True" Text='<%# Bind("HW_Storage") %>'></asp:TextBox></td>
                                    <td style="width: 166px">
                                        </td>
                                    <td style="width: 91px">
                                        </td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        </td>
                                    <td style="width: 151px">
                                        </td>
                                    <td style="width: 160px">
                                        HW RAID LES</td>
                                    <td style="width: 115px">
                                        <asp:TextBox ID="TextBox14" runat="server" ReadOnly="True" Text='<%# Bind("HW_RAID_LES") %>'></asp:TextBox></td>
                                    <td style="width: 166px">
                                        </td>
                                    <td style="width: 91px">
                                        </td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        HW Other</td>
                                    <td colspan="5">
                                        <asp:TextBox ID="TextBox17" runat="server" ReadOnly="True" Text='<%# Bind("HW_Other") %>' Height="80px" TextMode="MultiLine" Width="435px" Font-Names="Verdana"></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 113px">
                                        Services</td>
                                    <td colspan="5">
                                        <asp:TextBox ID="TextBox27" runat="server" ReadOnly="True" Text='<%# Bind("Services") %>' Height="80px" TextMode="MultiLine" Width="435px" Font-Names="Verdana"></asp:TextBox></td>
                                </tr>
                            </table>
                            <br />
                            <table style="font-size: 10pt; font-family: Verdana">
                                <tr>
                                    <td align="right" style="width: 130px">
                                        <asp:Button ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
                                            Height="26px" Text="Izmijeni" Width="60px" /></td>
                                    <td style="width: 130px">
                                        <asp:Button ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
                                            Height="26px" OnClick="NewButton_Click" Text="Novi" Width="60px" /></td>
                                </tr>
                            </table>
                            &nbsp;
                        </ItemTemplate>
                        <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
                        <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
                        <EditRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
                    </asp:FormView>
                    <asp:SqlDataSource ID="servers_form" runat="server" ConnectionString="<%$ ConnectionStrings:CMString %>" InsertCommand="INSERT INTO [Servers] ([Name], [SystemID], [Asset_Number], [Product], [HW_Model], [HW_CPU], [HW_CPU_SPEED], [HW_Memory], [HW_HDD1], [HW_HDD2], [HW_HDD_type], [HW_RAID_Level], [HW_RAID_LES], [HW_Storage], [HW_Array_ctl], [HW_Other], [OS], [OS_Level], [Comment], [Domain], [Location], [Organizaciona_jedinica], [IP_Address], [ILO_Address], [Type], [Services], [Owner], [Rack_Number], [Warranty_Date], [Installed_Date], [Support_Contact_Name], [Serial_Number], [Part_Number], [Purchase_Date], [FV]) VALUES (@Name, @SystemID, @Asset_Number, @Product, @HW_Model, @HW_CPU, @HW_CPU_SPEED, @HW_Memory, @HW_HDD1, @HW_HDD2, @HW_HDD_type, @HW_RAID_Level, @HW_RAID_LES, @HW_Storage, @HW_Array_ctl, @HW_Other, @OS, @OS_Level, @Comment, @Domain, @Location, @Organizaciona_jedinica, @IP_Address, @ILO_Address, @Type, @Services, @Owner, @Rack_Number, @Warranty_Date, @Installed_Date, @Support_Contact_Name, @Serial_Number, @Part_Number, @Purchase_Date, @FV)"
                        SelectCommand="SELECT * FROM [Servers] WHERE ([Name] = @Name)" UpdateCommand="UPDATE [Servers] SET [Name] = @Name, [SystemID] = @SystemID, [Asset_Number] = @Asset_Number, [Product] = @Product, [HW_Model] = @HW_Model, [HW_CPU] = @HW_CPU, [HW_CPU_SPEED] = @HW_CPU_SPEED, [HW_Memory] = @HW_Memory, [HW_HDD1] = @HW_HDD1, [HW_HDD2] = @HW_HDD2, [HW_HDD_type] = @HW_HDD_type, [HW_RAID_Level] = @HW_RAID_Level, [HW_RAID_LES] = @HW_RAID_LES, [HW_Storage] = @HW_Storage, [HW_Array_ctl] = @HW_Array_ctl, [HW_Other] = @HW_Other, [OS] = @OS, [OS_Level] = @OS_Level, [Comment] = @Comment, [Domain] = @Domain, [Location] = @Location, [Organizaciona_jedinica] = @Organizaciona_jedinica, [IP_Address] = @IP_Address, [ILO_Address] = @ILO_Address, [Type] = @Type, [Services] = @Services, [Owner] = @Owner, [Rack_Number] = @Rack_Number, [Warranty_Date] = @Warranty_Date, [Installed_Date] = @Installed_Date, [Support_Contact_Name] = @Support_Contact_Name, [Serial_Number] = @Serial_Number,  [Part_Number] = @Part_Number, [Purchase_Date] = @Purchase_Date, [FV] = @FV WHERE [ID] = @ID">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="ListBox1" Name="Name" PropertyName="SelectedValue"
                                Type="String" />
                        </SelectParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="Name" Type="String" />
                            <asp:Parameter Name="SystemID" Type="String" />
                            <asp:Parameter Name="Asset_Number" Type="String" />
                            <asp:Parameter Name="Product" Type="String" />
                            <asp:Parameter Name="HW_Model" Type="String" />
                            <asp:Parameter Name="HW_CPU" Type="String" />
                            <asp:Parameter Name="HW_CPU_SPEED" Type="String" />
                            <asp:Parameter Name="HW_Memory" Type="String" />
                            <asp:Parameter Name="HW_HDD1" Type="String" />
                            <asp:Parameter Name="HW_HDD2" Type="String" />
                            <asp:Parameter Name="HW_HDD_type" Type="String" />
                            <asp:Parameter Name="HW_RAID_Level" Type="String" />
                            <asp:Parameter Name="HW_RAID_LES" Type="String" />
                            <asp:Parameter Name="HW_Storage" Type="String" />
                            <asp:Parameter Name="HW_Array_ctl" Type="String" />
                            <asp:Parameter Name="HW_Other" Type="String" />
                            <asp:Parameter Name="OS" Type="String" />
                            <asp:Parameter Name="OS_Level" Type="String" />
                            <asp:Parameter Name="Comment" Type="String" />
                            <asp:Parameter Name="Domain" Type="String" />
                            <asp:Parameter Name="Location" Type="String" />
                            <asp:Parameter Name="Organizaciona_jedinica" Type="String" />
                            <asp:Parameter Name="IP_Address" Type="String" />
                            <asp:Parameter Name="ILO_Address" Type="String" />
                            <asp:Parameter Name="Type" Type="String" />
                            <asp:Parameter Name="Services" Type="String" />
                            <asp:Parameter Name="Owner" Type="String" />
                            <asp:Parameter Name="Rack_Number" Type="String" />
                            <asp:Parameter Name="Warranty_Date" Type="DateTime" />
                            <asp:Parameter Name="Installed_Date" Type="DateTime" />
                            <asp:Parameter Name="Support_Contact_Name" Type="String" />
                            <asp:Parameter Name="Serial_Number" />
                            <asp:Parameter Name="Part_Number" Type="String" />
                            <asp:Parameter Name="Purchase_Date" Type="DateTime" />
                            <asp:Parameter Name="FV" Type="String" />
                            <asp:Parameter Name="ID" Type="Int32" />
                        </UpdateParameters>
                        <InsertParameters>
                            <asp:Parameter Name="Name" Type="String" />
                            <asp:Parameter Name="SystemID" Type="String" />
                            <asp:Parameter Name="Asset_Number" Type="String" />
                            <asp:Parameter Name="Product" Type="String" />
                            <asp:Parameter Name="HW_Model" Type="String" />
                            <asp:Parameter Name="HW_CPU" Type="String" />
                            <asp:Parameter Name="HW_CPU_SPEED" Type="String" />
                            <asp:Parameter Name="HW_Memory" Type="String" />
                            <asp:Parameter Name="HW_HDD1" Type="String" />
                            <asp:Parameter Name="HW_HDD2" Type="String" />
                            <asp:Parameter Name="HW_HDD_type" Type="String" />
                            <asp:Parameter Name="HW_RAID_Level" Type="String" />
                            <asp:Parameter Name="HW_RAID_LES" Type="String" />
                            <asp:Parameter Name="HW_Storage" Type="String" />
                            <asp:Parameter Name="HW_Array_ctl" Type="String" />
                            <asp:Parameter Name="HW_Other" Type="String" />
                            <asp:Parameter Name="OS" Type="String" />
                            <asp:Parameter Name="OS_Level" Type="String" />
                            <asp:Parameter Name="Comment" Type="String" />
                            <asp:Parameter Name="Domain" Type="String" />
                            <asp:Parameter Name="Location" Type="String" />
                            <asp:Parameter Name="Organizaciona_jedinica" Type="String" />
                            <asp:Parameter Name="IP_Address" Type="String" />
                            <asp:Parameter Name="ILO_Address" Type="String" />
                            <asp:Parameter Name="Type" Type="String" />
                            <asp:Parameter Name="Services" Type="String" />
                            <asp:Parameter Name="Owner" Type="String" />
                            <asp:Parameter Name="Rack_Number" Type="String" />
                            <asp:Parameter Name="Warranty_Date" Type="DateTime" />
                            <asp:Parameter Name="Installed_Date" Type="DateTime" />
                            <asp:Parameter Name="Support_Contact_Name" Type="String" />
                            <asp:Parameter Name="Serial_Number" />
                            <asp:Parameter Name="Part_Number" Type="String" />
                            <asp:Parameter Name="Purchase_Date" Type="DateTime" />
                            <asp:Parameter Name="FV" Type="String" />
                        </InsertParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
        </table>
        </div>
    </form>
</body>
</html>

Open in new window

0
David H.H.LeeCommented:
Try this casting:
eg:
  fizvi = CType(FormView1.FindControl("RadioButtonList2"),RadioButtonList)
  ilotext = CType(FormView1.FindControl("TextBox25"),TextBox)
     
0
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

kahvedzicAuthor Commented:
Now I did this:

    Protected Sub FormView1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.Load
        Dim fizvi As RadioButtonList
        Dim ilotext As TextBox
        fizvi = CType(FormView1.FindControl("RadioButtonList2"), RadioButtonList)
        ilotext = CType(FormView1.FindControl("TextBox25"), TextBox)
        If fizvi.SelectedValue = "V" Then
            ilotext.Enabled = False
        Else
            ilotext.Enabled = True
        End If
    End Sub

and on page load I got error: Object reference not set to an instance of an object.
on this line:  If fizvi.SelectedValue = "V" Then

when I step through code fizvi is Nothing and Ilotext is Nothing too. Am I using wrong event or casting isnt OK since fizvi and ilotext are nothing.
0
David H.H.LeeCommented:
Try in FormView1's ItemCreated event instead of Load event.
eg:
Protected Sub FormView1_ItemCreated(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.ItemCreated
   
0
kahvedzicAuthor Commented:
This is what I did. Enable auto post back on radio button list. On page load event add

Dim fizvi As RadioButtonList
Dim ilotext As TextBox
        If FormView1.CurrentMode = FormViewMode.Insert Then
            fizvi = DirectCast(FormView1.FindControl("RadioButtonList1"), RadioButtonList)
            ilotext = DirectCast(FormView1.FindControl("ILO_AddressTextBox"), TextBox)
            If fizvi.SelectedValue = "V" Then
                ilotext.Enabled = False
            Else
                ilotext.Enabled = True
            End If

        End If

Didi this for Update mode also and it is working now.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.