What is this all about? Please please help!

        Dim btnEdit As Button = newJob.FindControl("btnEdit")
        btnEdit.Visible = "True"

As you can see my webform is called "newJob" and the Button control i am trying to access is called btnEdit i have an if statement which checks if the user is in a certain role and then i want to display the control but i get

Object reference not set to an instance of an object.

I know this is an error meaning in cannot find btnEdit, but i use this way of accesing my controls all the time and it works fine is it just asp:buttons that don't work like this?

Thanks

Matt 

 

0
intrigue
3/4/2007 7:34:25 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

13 Replies
885 Views

Similar Articles

[PageSpeed] 45

if btnEdit is nested inside of another control that is also a naming container, then FindControl would not find it.

FindControl only searches the namingcontain from where it is called.

Is your button nested inside of something?

 


Mike Banavige
~~~~~~~~~~~~

Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
0
mbanavige
3/4/2007 7:38:55 PM

No its not and i can access other controls which are only a few lines above or below that control for example this works

                Dim helpdeskCategoryDD As DropDownList = newJob.FindControl("helpdeskCategoryDD")
                helpdeskCategoryDD.Enabled = "True"
Strange? Any other ideas.

Matt 

0
intrigue
3/4/2007 7:56:30 PM

check the spelling of your controlid - and check to see if you are using the same case too.

 


Mike Banavige
~~~~~~~~~~~~

Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
0
mbanavige
3/4/2007 8:05:53 PM

Spelling and case is all correct and i am using VB i don't know if thats any more help

Thanks

matt 

0
intrigue
3/4/2007 10:50:34 PM

if the button is directly on your form, then why not simply access it directly in your code-behind?

Me.btnEdit.Visible = True
 
Mike Banavige
~~~~~~~~~~~~

Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
0
mbanavige
3/4/2007 10:53:38 PM

hello Matt,

try this

 Dim helpdeskCategoryDD As DropDownList = CType(newJob.FindControl("helpdeskCategoryDD"),DropDownList)
                helpdeskCategoryDD.Enabled = "True"

I think you should cast the control to DropDownList

hope it helps,

Jessica


Jessica Cao
Sincerely,
Microsoft Online Community Support


“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
0
Jessica
3/5/2007 1:08:35 AM

Hey jessica thanks but you must have misread my post, the Drop down list works fine its the Button that doesn't

As for using Me. that doesn't work as it says its not part of the webform.

The button control is within my webform called newJob and then inside the ItemTemplate so i tried newJob.ItemTemplate.btnEdit.visible = True but it says that btnEdit is not part of the System.Web.UI.ITemplate

Thanks

Matt
 

0
intrigue
3/5/2007 10:46:55 AM

it sounds like your button is actually nested inside of something.

perhaps you could post some of your markup so we can see what you have.

 


Mike Banavige
~~~~~~~~~~~~

Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
0
mbanavige
3/5/2007 11:09:51 AM

hello Matt,

thank you for correcting.

I think if you post some of your mark up code about the DropDownList and the button, it would be helpful

for us to track down the problem.

Thank you,

Jessica


Jessica Cao
Sincerely,
Microsoft Online Community Support


“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
0
Jessica
3/5/2007 1:40:41 PM

Ok here goes

 <asp:Content ID="Content2" ContentPlaceHolderID="mainContent" Runat="Server">
    <asp:Label ID="confirmation" runat="server"></asp:Label>
        <asp:FormView ID="newJob" runat="server" DataKeyNames="intJobId" DataSourceID="jobDetailsDS" Width="700px" AllowPaging="True">
        <InsertItemTemplate>
            <table class="tblFormEdit" align="center">
                <tr class="tableHeader">
                    <td colspan="3">New Job</td>
                </tr>
                <tr class="tableRow">
                    <td colspan="2">
                        <strong>Title: (a short summary of your problem)
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="jobTitle"
                                ErrorMessage="* You have not entered a title." ForeColor="Black"></asp:RequiredFieldValidator><br />
                        </strong>
                    <asp:TextBox cssClass="textbox" ID="jobTitle" runat="server" Text='<%# Bind("strJobTitle") %>' Width="630px"></asp:TextBox>&nbsp;
                    </td>
                    <td colspan="1" style="width: 225px">
                        Priority:<br />
                            <asp:DropDownList ID="jobPriority" runat="server" DataSourceID="helpdeskPriorityDS"
                                DataTextField="priorityName" DataValueField="id" SelectedValue='<%# Bind("intJobPriorityId") %>'>
                            </asp:DropDownList><asp:SqlDataSource ID="helpdeskPriorityDS" runat="server" ConnectionString="<%$ ConnectionStrings:promanConn %>"
                                SelectCommand="SELECT * FROM [tblPriority] ORDER BY [id]"></asp:SqlDataSource>
                    </td>
                </tr>
                <tr class="tableRowAlt">
                     <td>
                        <strong>Category:</strong><br />
                        <asp:DropDownList ID="helpdeskCategoryDD" runat="server"
                            DataSourceID="helpdeskCategoryDS" DataTextField="strProblemCatName" DataValueField="intProblemCatId"
                            SelectedValue='<%# bind("intJobCategoryId") %>' Enabled="false">
                        </asp:DropDownList><asp:SqlDataSource ID="helpdeskCategoryDS" runat="server" ConnectionString="<%$ ConnectionStrings:promanConn %>"
                            SelectCommand="SELECT [intProblemCatId], [strProblemCatName] FROM [tblProblemCategoriesLookup] ORDER BY [strProblemCatName]">
                        </asp:SqlDataSource>
                    </td>                  
                    <td>
                        <strong>Reported By:<br /></strong>
                        <asp:DropDownList ID="jobReportedBy" runat="server" DataSourceID="helpdeskStaffDS"
                            DataTextField="staffName" DataValueField="id" SelectedValue='<%# bind("intJobStaffId") %>' Enabled="false">
                        </asp:DropDownList><asp:SqlDataSource ID="helpdeskStaffDS" runat="server" ConnectionString="<%$ ConnectionStrings:promanConn %>"
                            SelectCommand="SELECT [staffName], [id] FROM [tblStaff] ORDER BY [staffName]"></asp:SqlDataSource>
                    </td>
                    <td>
                        <strong>Assigned To:</strong>
                        <asp:DropDownList ID="jobAssignedTo" runat="server" DataSourceID="itStaffDS"
                            DataTextField="staffName" DataValueField="id" SelectedValue='<%# Bind("intJobUserId") %>' Enabled="false">
                        </asp:DropDownList><asp:SqlDataSource ID="itStaffDS" runat="server" ConnectionString="<%$ ConnectionStrings:promanConn %>"
                            SelectCommand="SELECT staffName, staffEmail, id FROM tblStaff WHERE staffDept = @staffDept">
                            <SelectParameters>
                                <asp:Parameter DefaultValue="1" Name="staffDept" Type="Int32" />
                                <asp:Parameter DefaultValue="True" Name="staffLive" Type="Boolean" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                    </td>
                </tr>
                <tr class="tableRow">
                    <td colspan="3">
                        <strong>Deadline:</strong><br />
                        <asp:TextBox cssClass="textbox" ID="dateJobDeadlineTb" runat="server" Text='<%# Bind("dateJobDeadline", "{0:D}") %>' Enabled="false">dd/mm/yyyy</asp:TextBox></td>
                </tr>   
                <tr class="tableRowAlt">
                    <td colspan="3">
                        <strong>
                        Details: (Please be as specific as possible)&nbsp;<asp:RequiredFieldValidator
                            ID="RequiredFieldValidator3" runat="server" ControlToValidate="jobDetails" ErrorMessage="* You have not entered any details."
                            ForeColor="Black"></asp:RequiredFieldValidator><br />
                            &nbsp;<asp:TextBox cssClass="textbox" ID="jobDetails" runat="server" Rows="5" Text='<%# bind("strJobDesc") %>'
                            TextMode="MultiLine" Width="718px"></asp:TextBox>&nbsp;
                    </td>
                </tr>
                <tr class="tableRowFooter">
                    <td colspan="3">
                        <asp:Button ID="insertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Add Job"></asp:Button>
                    </td>
                </tr>
            </table>
        </InsertItemTemplate>
        <ItemTemplate>
            <table class="tblFormEdit" align="center" style="width: 772px">
                <tr class="tableHeader">
                    <td colspan="2">
                    <div id="refFloat">
                        #<asp:Label ID="id" runat="server" Text='<%# Eval("intJobId") %>'></asp:Label>
                    </div>
                    <h2><asp:Label ID="projTitleLabel" runat="server" Text='<%# Bind("strJobTitle") %>'></asp:Label></h2>
                    </td>
                </tr>
                <tr class="tableRowAlt">
                    <td>
                        <strong>Created:</strong>
                        <asp:Label ID="dateJobLoggedLabel" runat="server" Text='<%# Bind("dateJobLogged", "{0:D}") %>'></asp:Label></td>
                    <td style="width: 344px">
                        <strong>Priority:</strong>
                        <asp:Label ID="intJobPriorityIdLabel" runat="server" Text='<%# Bind("intJobPriorityId") %>'></asp:Label></td>
                </tr>
                <tr class="tableRow">
                    <td colspan="2">
                        <strong>Details:</strong>
                        <asp:Label ID="strJobDescLabel" runat="server" Text='<%# Bind("strJobDesc") %>'></asp:Label></td>
                </tr>
                <tr class="tableRowAlt">
                    <td colspan="2">
                        <strong>Category:</strong>
                        <asp:Label ID="intJobCategoryIdLabel" runat="server" Text='<%# Bind("strProblemCatName") %>'></asp:Label>&nbsp;
                    </td>
                </tr>
                <tr class="tableRow">
                    <td>
                        <strong>Reported By:</strong><asp:Label ID="intJobStaffIdLabel" runat="server" Text='<%# Bind("staffName") %>'></asp:Label></td>
                    <td style="width: 344px">
                        <strong>Assigned To:</strong>
                        <asp:Label ID="intJobUserIdLabel" runat="server" Text='<%# Bind("UserName") %>'></asp:Label></td>
                </tr>
                <tr class="tableRowAlt">
                    <td colspan="2">
                        Deadline:
                        <asp:Label ID="dateJobDeadlineLabel" runat="server" Text='<%# Bind("dateJobDeadline", "{0:D}") %>'></asp:Label></td>  
                </tr>
                <tr class="tableRowFooter">
                    <td colspan="2">
                        <asp:Button ID="btnEdit" runat="server" CausesValidation="True" CommandName="Edit" Text="Edit" Visible="True"></asp:Button>
                    </td>
                </tr>
            </table>
        </ItemTemplate>
        <EditItemTemplate>
            <table class="tblFormEdit" width="700">
                <tr class="tableHeader">
                    <td colspan="3">Edit Job</td>
                </tr>
                <tr class="tableRow">
                    <td colspan="3">
                        <strong>Title:</strong><asp:TextBox cssClass="textbox" ID="projTitleLabel" runat="server" Text='<%# Bind("strJobTitle") %>' Width="642px"></asp:TextBox>
                    </td>
                </tr>
                <tr class="tableRowAlt">
                    <td>
                        <strong>Created:</strong>
                        <asp:Label ID="dateJobLoggedLabel" runat="server" Text='<%# Bind("dateJobLogged", "{0:D}") %>'></asp:Label>
                        &nbsp;
                    </td>
                    <td><asp:CheckBox ID="boolJobComplete" runat="server" Checked='<%# Bind("boolJobCompleted") %>' /> Complete?
                    </td>
                    <td valign="top">
                        <strong>Priority:
                        <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="helpdeskPriorityDS"
                            DataTextField="priorityName" DataValueField="id" SelectedValue='<%# Bind("intJobPriorityId") %>'>
                        </asp:DropDownList>
                    </td>               
                </tr>
                <tr class="tableRow">
                    <td>
                        <strong>Reported By:&nbsp;<br />
                        </strong>
                        <asp:DropDownList ID="jobReportedBy" runat="server" DataSourceID="helpdeskStaffDS"
                            DataTextField="staffName" DataValueField="id" SelectedValue='<%# bind("intJobStaffId") %>'>
                        </asp:DropDownList><asp:SqlDataSource ID="helpdeskStaffDS" runat="server" ConnectionString="<%$ ConnectionStrings:promanConn %>"
                            SelectCommand="SELECT [staffName], [id] FROM [tblStaff]"></asp:SqlDataSource>
                    </td>
                    <td>
                        <strong>Assigned To:</strong>&nbsp;<br />
                        <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="helpdeskStaffDS2"
                            DataTextField="staffName" DataValueField="id" SelectedValue='<%# Bind("intJobUserId") %>'>
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="helpdeskStaffDS2" runat="server" ConnectionString="<%$ ConnectionStrings:promanConn %>"
                            SelectCommand="SELECT [staffName], [id] FROM [tblStaff] WHERE ([staffDept] = @staffDept)">
                            <SelectParameters>
                                <asp:Parameter DefaultValue="1" Name="staffDept" Type="Int32" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                    </td>
                    <td>
                        <strong>Category:</strong>&nbsp;<br />
                        <asp:DropDownList ID="helpdeskCategoryDD" runat="server"
                            DataSourceID="helpdeskCategoryDS" DataTextField="strProblemCatName" DataValueField="intProblemCatId"
                            SelectedValue='<%# bind("intJobCategoryId") %>'>
                        </asp:DropDownList><asp:SqlDataSource ID="helpdeskCategoryDS" runat="server" ConnectionString="<%$ ConnectionStrings:promanConn %>"
                            SelectCommand="SELECT [intProblemCatId], [strProblemCatName] FROM [tblProblemCategoriesLookup] ORDER BY [strProblemCatName]">
                        </asp:SqlDataSource>
                    </td>
                </tr>
                <tr class="tableRowAlt">
                    <td colspan="3">
                        <asp:SqlDataSource ID="helpdeskPriorityDS" runat="server" ConnectionString="<%$ ConnectionStrings:promanConn %>"
                            SelectCommand="SELECT * FROM [tblPriority]"></asp:SqlDataSource>
                        Details:
                        <br />
                        <asp:TextBox cssClass="textbox" ID="TextBox1" runat="server" Rows="5" Text='<%# bind("strJobDesc") %>'
                        TextMode="MultiLine" Width="682px"></asp:TextBox></td>
                </tr>

                <tr class="tableRow">
                    <td colspan="3">
                        <strong>Solution:</strong>&nbsp;<br />
                        <asp:TextBox cssClass="textbox" ID="TextBox2" runat="server" Rows="5"
                            Text='<%# Bind("strJobSolution") %>' TextMode="MultiLine" Width="679px"></asp:TextBox></td>
                </tr>   
                <tr class="tableRowAlt">
                    <td colspan="3">
                        <strong>Deadline:</strong>
                        <asp:Label ID="dateJobDeadlineLabel" runat="server" Text='<%# Bind("dateJobDeadline", "{0:D}") %>'></asp:Label></td>
                </tr>                   
                <tr class="tableRowFooter">
                    <td>
                    <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                        Text="Update">
                    </asp:Button>
                    </td>
                    <td>
                    <asp:Button ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                        Text="Cancel">
                    </asp:Button>
                    </td>
                    <td>
                    <asp:Button ID="UpdateDeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
                        Text="Delete">
                    </asp:Button>  
                    </td>
                </tr>
            </table>
        </EditItemTemplate>
    </asp:FormView>
    <asp:SqlDataSource ID="emailAddressDS" runat="server" ConnectionString="<%$ ConnectionStrings:promanConn %>" SelectCommand="SELECT [staffEmail] FROM [tblStaff] WHERE ([id] = @id)">
        <SelectParameters>
            <asp:FormParameter FormField="DropDownList2" Name="id" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <br />
    <asp:SqlDataSource ID="jobDetailsDS" runat="server" ConnectionString="<%$ ConnectionStrings:promanConn %>"
    SelectCommand="SELECT tblJobs.intJobId, tblJobs.intJobStaffId, tblJobs.intJobUserId, tblJobs.intJobCategoryId, tblJobs.strJobTitle, tblJobs.strJobDesc, tblJobs.strJobNotes, tblJobs.dateJobLogged, tblJobs.dateJobDeadline, tblJobs.dateJobCompleted, tblJobs.intJobPriorityId, tblJobs.strJobSolution, tblJobs.boolJobCompleted, tblPriority.priorityName, tblPriority.id, tblPriority.priorityOrder, tblStaff.staffName, tblStaff.id AS staffID, tblProblemCategoriesLookup.strProblemCatName, tblProblemCategoriesLookup.intProblemCatId, tblStaff_1.id AS Expr1, tblStaff_1.staffName AS UserName FROM tblJobs INNER JOIN tblPriority ON tblJobs.intJobPriorityId = tblPriority.id INNER JOIN tblStaff ON tblJobs.intJobStaffId = tblStaff.id INNER JOIN tblProblemCategoriesLookup ON tblJobs.intJobCategoryId = tblProblemCategoriesLookup.intProblemCatId INNER JOIN tblStaff AS tblStaff_1 ON tblJobs.intJobUserId = tblStaff_1.id WHERE (tblJobs.intJobId = @intJobId)"
    InsertCommand="INSERT INTO tblJobs(intJobStaffId, intJobUserId, intJobCategoryId, strJobTitle, strJobDesc, strJobNotes, dateJobLogged, dateJobDeadline, intJobPriorityId, boolJobCompleted) VALUES (@intJobStaffId, 56 , 39, @strJobTitle, @strJobDesc, @strJobNotes,{ fn NOW() }, { fn NOW() }, @intJobPriorityId, 0)"
    DeleteCommand="DELETE FROM [tblJobs] WHERE [intJobId] = @intJobId"
    UpdateCommand="UPDATE [tblJobs] SET [intJobStaffId] = @intJobStaffId, [intJobUserId] = @intJobUserId, [intJobCategoryId] = @intJobCategoryId, [strJobTitle] = @strJobTitle, [strJobDesc] = @strJobDesc, [strJobNotes] = @strJobNotes, [dateJobLogged] = @dateJobLogged, [dateJobDeadline] = @dateJobDeadline, [dateJobCompleted] = @dateJobCompleted, [intJobPriorityId] = @intJobPriorityId, [strJobSolution] = @strJobSolution, [boolJobCompleted] = @boolJobCompleted WHERE [intJobId] = @intJobId">       
        <SelectParameters>
            <asp:ControlParameter ControlID="gvActiveJobs" Name="intJobId" PropertyName="SelectedValue" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="intJobStaffId" Type="Int32" />
            <asp:Parameter Name="strJobTitle" Type="String" />
            <asp:Parameter Name="strJobDesc" Type="String" />
            <asp:Parameter Name="strJobNotes" Type="String" />
            <asp:Parameter Name="intJobPriorityId" Type="Int32" />
        </InsertParameters>
        <DeleteParameters>
            <asp:Parameter Name="intJobId" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="intJobStaffId" Type="Int32" />
            <asp:Parameter Name="intJobUserId" Type="Int32" />
            <asp:Parameter Name="intJobCategoryId" Type="Int32" />
            <asp:Parameter Name="strJobTitle" Type="String" />
            <asp:Parameter Name="strJobDesc" Type="String" />
            <asp:Parameter Name="strJobNotes" Type="String" />
            <asp:Parameter Name="dateJobLogged" Type="DateTime" />
            <asp:Parameter Name="dateJobDeadline" Type="DateTime" />
            <asp:Parameter Name="dateJobCompleted" Type="DateTime" />
            <asp:Parameter Name="intJobPriorityId" Type="Int32" />
            <asp:Parameter Name="strJobSolution" Type="String" />
            <asp:Parameter Name="boolJobCompleted" Type="Boolean" />
            <asp:Parameter Name="intJobId" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="dsEmail" runat="server" ConnectionString="<%$ ConnectionStrings:promanConn %>"
        SelectCommand="SELECT [staffEmail] FROM [tblStaff] WHERE ([id] = @id)">
        <SelectParameters>
            <asp:FormParameter FormField="DropDownList2" Name="id" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:GridView ID="gvActiveJobs" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="False" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None"
        BorderWidth="1px" CellPadding="3" DataSourceID="allJobsDS" GridLines="Horizontal" Width="771px" DataKeyNames="intJobId">
        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
        <Columns>
            <asp:CommandField ShowSelectButton="True" />
            <asp:BoundField DataField="intJobId" HeaderText="Ref #" SortExpression="intJobId" />
            <asp:BoundField DataField="strJobTitle" HeaderText="Title" SortExpression="strJobTitle" />
            <asp:BoundField DataField="techName" HeaderText="Assigned" SortExpression="techName" />
            <asp:BoundField DataField="staffName" HeaderText="From" SortExpression="staffName" />
            <asp:BoundField DataField="deptName" HeaderText="Department" SortExpression="deptName" />
            <asp:BoundField DataField="dateJobDeadline" HeaderText="Deadline" SortExpression="dateJobDeadline" DataFormatString="{0:d}" HtmlEncode="False" />
            <asp:BoundField DataField="priorityName" HeaderText="Priority" SortExpression="priorityName" />
        </Columns>
        <RowStyle BackColor="#A185A2" ForeColor="White" Font-Bold="True" />
        <SelectedRowStyle BackColor="#F2EFF3" Font-Bold="True" ForeColor="#805A83" />
        <PagerStyle BackColor="#805A83" Font-Bold="True" ForeColor="#F7F7F7" HorizontalAlign="Right" />
        <HeaderStyle BackColor="#805A83" Font-Bold="True" ForeColor="#F7F7F7" />
        <AlternatingRowStyle BackColor="#C8B8CA" ForeColor="#5D3367" Font-Bold="True" />
        <EmptyDataTemplate>
            <div class="tableRow">
                <asp:Label ID="lblNoJobs" runat="server" Text="There are currently no Helpdesk jobs."></asp:Label>
            </div>
        </EmptyDataTemplate>
    </asp:GridView>
    <asp:SqlDataSource ID="allJobsDS" runat="server" ConnectionString="<%$ ConnectionStrings:promanConn %>"
        SelectCommand="SELECT tblJobs.intJobId, tblJobs.intJobStaffId, tblJobs.intJobUserId, tblJobs.strJobTitle, tblJobs.intJobPriorityId, tblJobs.dateJobDeadline, tblJobs.dateJobCompleted, tblStaff.staffName, tblStaff.staffDept, tblDept.deptName, tblStaff_1.staffName AS techName, tblPriority.priorityName, tblPriority.priorityOrder FROM tblJobs INNER JOIN tblStaff ON tblJobs.intJobStaffId = tblStaff.id INNER JOIN tblDept ON tblStaff.staffDept = tblDept.id INNER JOIN tblStaff AS tblStaff_1 ON tblJobs.intJobUserId = tblStaff_1.id INNER JOIN tblPriority ON tblJobs.intJobPriorityId = tblPriority.id WHERE (tblJobs.boolJobCompleted = 0) ORDER BY tblPriority.priorityOrder ASC, tblJobs.dateJobDeadline">
    </asp:SqlDataSource>
    <br />
</asp:Content>

Thats my webform and my code behind

Imports System.Data.SqlClient
Imports System.Data
Imports System.IO

Partial Class Helpdesk_Default
    Inherits System.Web.UI.Page
    Dim uploads As New ArrayList
    Dim curStatus As Label ' Sets the label for current status
    Dim X = 0
    Dim dest As String
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        dest = Request.QueryString("dest")
        curStatus = Master.FindControl("currentStatus")
        curStatus.Text = "Welcome to the helpdesk.<br />Please select a job to see more information."
        If dest = "newJob" Then
            newJob.DefaultMode = FormViewMode.Insert
            gvActiveJobs.Visible = "False"
            If User.IsInRole("Technicians") Then
                Dim helpdeskCategoryDD As DropDownList = newJob.FindControl("helpdeskCategoryDD")
                helpdeskCategoryDD.Enabled = "True"
                Dim jobReportedBy As DropDownList = newJob.FindControl("jobReportedBy")
                jobReportedBy.Enabled = "True"
                Dim jobAssignedTo As DropDownList = newJob.FindControl("jobAssignedTo")
                jobAssignedTo.Enabled = "True"
                Dim dateJobDeadlineTb As TextBox = newJob.FindControl("dateJobDeadlineTb")
                dateJobDeadlineTb.Enabled = "True"
            Else
                Dim dateJobDeadlineTb As TextBox = newJob.FindControl("dateJobDeadlineTb")
                dateJobDeadlineTb.Text = ""
            End If
        ElseIf dest = "completeJobs" Then
            allJobsDS.SelectCommand = "SELECT tblJobs.intJobId, tblJobs.intJobStaffId, tblJobs.intJobUserId, tblJobs.strJobTitle, tblJobs.intJobPriorityId, tblJobs.dateJobDeadline, tblJobs.dateJobCompleted, tblStaff.staffName, tblStaff.staffDept, tblDept.deptName, tblStaff_1.staffName AS techName, tblPriority.priorityName FROM tblJobs INNER JOIN tblStaff ON tblJobs.intJobStaffId = tblStaff.id INNER JOIN tblDept ON tblStaff.staffDept = tblDept.id INNER JOIN tblStaff AS tblStaff_1 ON tblJobs.intJobUserId = tblStaff_1.id INNER JOIN tblPriority ON tblJobs.intJobPriorityId = tblPriority.id WHERE (tblJobs.boolJobCompleted = 1) ORDER BY tblPriority.priorityName DESC, tblJobs.dateJobDeadline"
        ElseIf dest = "unassigned" Then
            allJobsDS.SelectCommand = "SELECT tblJobs.intJobId, tblJobs.intJobStaffId, tblJobs.intJobUserId, tblJobs.strJobTitle, tblJobs.intJobPriorityId, tblJobs.dateJobDeadline, tblJobs.dateJobCompleted, tblStaff.staffName, tblStaff.staffDept, tblDept.deptName, tblStaff_1.staffName AS techName, tblPriority.priorityName, tblPriority.priorityOrder FROM tblJobs INNER JOIN tblStaff ON tblJobs.intJobStaffId = tblStaff.id INNER JOIN tblDept ON tblStaff.staffDept = tblDept.id INNER JOIN tblStaff AS tblStaff_1 ON tblJobs.intJobUserId = tblStaff_1.id INNER JOIN tblPriority ON tblJobs.intJobPriorityId = tblPriority.id WHERE (tblJobs.intJobUserId = 56) ORDER BY tblPriority.priorityOrder ASC, tblJobs.dateJobDeadline"
            Dim lblNoJobs As Label = newJob.FindControl("lblNoJobs")
            lblNoJobs.Text = "Test"
        End If

    End Sub

    Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim tempPath = "C:\Inetpub\wwwroot\proman\upload\"
        Dim fuUpload As FileUpload = newJob.FindControl("fuUpload")
        Dim lblUploadConf As Label = newJob.FindControl("lblUploadConf")
        If fuUpload.HasFile Then
            Directory.CreateDirectory(tempPath & Session("session_id"))
            tempPath &= Session("session_id") & "\"
            Dim fuUploadSize = fuUpload.PostedFile.ContentLength \ 1000
            fuUpload.SaveAs(tempPath & fuUpload.FileName)
            lblUploadConf.Text &= "<br /><a href='../upload/" & Session("session_id") & "/" & fuUpload.FileName & "'>" & fuUpload.FileName & "</a> " & fuUploadSize & "KB"
        Else
            lblUploadConf.Text = "No uploaded file" & Session("session_id")
        End If
    End Sub

    Protected Sub gvActiveJobs_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvActiveJobs.SelectedIndexChanged
        gvActiveJobs.Visible = "False"
        'Dim btnEdit As Button = newJob.FindControl("btnEdit")
        'btnEdit.Visible = "True"
    End Sub

    Protected Sub newJob_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertedEventArgs) Handles newJob.ItemInserted
        newJob.Visible = "False"
        confirmation.Text = "Thanks for adding a new job.<br />" _
                            & "We will endevour to deal with your problem as soon as possible.<br />" _
                            & "<a href='default.aspx'>Click here to continue</a>"
    End Sub
End Class

Any help appreciated as well as any suggestions regarding my code.

Thanks 

 

0
intrigue
3/5/2007 4:27:41 PM

You see i am getting the error again here

Dim lblNoJobs As Label = newJob.FindControl("lblNoJobs")
lblNoJobs.Text = "Test"
ARGH!!!!!

Matt 

0
intrigue
3/5/2007 4:37:07 PM
I think the problem is that your button is inside an <ItemTemplate> so is not necessarily part of the page. Unless the formview's mode is set to read only that <ItemTemplate> won't be used so that button control won't be part of the control collection and you can't access it. The controls that do work (the dropdown) seem to be in the insert item template so that is probably the one that is normally selected so those are accessible. So I think you need to make sure that the formview is set to the mode you actually want displayed and then only work with controls in that view because the others won't be shown anyway.
If this post answered your question please remember to 'Mark as Answer'!
0
bpag
3/5/2007 5:03:59 PM

No the other templates do get accessed as i use the buttons with commandtypes on them so that cant be it and besides my default is ItemTemplate and i can access parts of the EditItemTemplate.

Thanks

matt 

0
intrigue
3/5/2007 6:56:12 PM
Reply:

Similar Artilces:

Please! Please! Please! Please! Help
I am very new to the Linux/Oracle/Perl world coming from a many many years of a Windows environment. I have self learned everything I know about this new environment. So far I have successfully installed Redhat 9 in an Intel box and have gotten Oracle 9I running correctly. I can run scripts via sqlplus, sqlldr etc. Perl (I think ver. 5.8.0) is running on the box and I can create and run scripts that do other processes but I have had no success in getting Perl to connect to the Oracle database to generate some reports. With my experience using MS-SQL there is no major issues w...

Please help, please, please
This is driving me crazy, I cannot find what is wrong with this thing. I have a custom module and after post back none of the following are processed : user, login, visibility, title, solpartmenu. None of it gets processed. Please help meYou died at the very end of your life Are you saying a skin, or a custom module. With custom modules you should not be dealing with tokens, I don't think they have anything to do with it. What module are you working with? No I am not using tokens, container skin is Classic skin that comes with DNN. I am talking about custom module. It has a text box a...

Please Please Please HELP!!!
I have posted this many times to no avail. I managed to publish the site somwhere despite being an intranet. I have published the site just in case I was not clear in explaining the prblem that I was having. Go to http://www.undg.ks.undp.org/test/login.aspx and login with userid: test password: test Click on 'search for cases' and then click on the search button (the dates are inserted automatically). Click on the paging and try to go to page 12,13,14,15 - any page really above page 11. Can you see what is happening? Below is the code that I am using. Please tell me wha...

Please Please Please help me out...
hello, our netware 6.0 file server can'nt connect the internet, we have a proxyserver with netware 6.0 and BM 3.8. can somebody please help me out i'm a newbie. hello, our netware 6.0 file server can'nt connect the internet, we have a proxyserver with netware 6.0 and BM 3.8. can somebody please help me out i'm a newbie. the file server ip is 192.20.71.1 the proxy ip is 192.20.71.252 akula_26@hotmail.com wrote: > our netware 6.0 file server can'nt connect the internet, we have a > proxyserver with netware 6.0 and BM 3.8. can somebody please hel...

Please Please Please help
I am trying to populate a second dropdownlist from the first. both dropdownlists are displayed inside the datagrid. I can populate the first one easily but my onselectedindexchanged event states: Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 195...

Please Help!! web parts and .net forms
This is a two part question. 1. i have a simple .net form that captures users input and i want to post to another form to show users input and data from a database into a data grid. In keep posting back to the first form. I have action and method set correctly on my first form, no idea why it post to same form. i even have a response.redirect in the click event of the button on the first form. 2. Does anyone know of any good site/web cast that step you through a basic web part for sharepoint 2007 i am using both visual studio 2005 and 2008. I heard that it is like a 12 step ...

Please please please
Folks, Please can we stop the petty bickering about banning or not banning............... The points have been made and in my opinion this is not the place to carry on with it. Once again - PLEASE! Regards Ian _____________________________________ Ian Sargent Education & Training Consulting Services Ltd Tel/Fax: 01344 644579 Mobile: 07970 847197 email: ians@etcs.co.uk www: http://www.etcs.co.uk _____________________________________ "Ian Sargent" <ians@nospam_etcs.co.uk> wrote in news:af7d6c$2da6$1 @news.grc.com: > Please can we st...

Please Please Please
I have only been asking for 4 years but PLEASE include a setting at the accounts level that sets the default compose to plain text if the account of type NEWS. Its a PITA to have to recall or remember to change my compose to plain text manually! Andre, It appears that in the past few days you have not received a response to your posting. That concerns us, and has triggered this automated reply. Has your problem been resolved? If not, you might try one of the following options: - Do a search of our knowledgebase at http://support.novell.com/search/kb_index.jsp - Check a...

Please, please, please ....
Name: Dean Talboys Email: deanatlouistalboysdotcom Product: Firefox Summary: Please, please, please .... Comments: Could you include a button on Firefox to register the currently viewed site as Firefox "Unfriendly"? I'm a developer of sophisticated Internet applications (check out http://www.psychl.com/ONE/cyclex.asp to see how much abuse a browser can take) and I always spend time to ensure my sites are IE and Firefox compatible. But I'm really frustrated at the number of sites that aren't Firefox compatible. You know, you get to the last screen of ...

PLEASE PLEASE PLEASE
Name: Nick Crain Email: n.crain_at_rogers.com Product: Firefox Summary: PLEASE PLEASE PLEASE Comments: Can you please include a rss feed indicator thing like IE 7 has. You know where every time you visit a page that has an rss feed available it beeps and then you can subscribe to it? That is such a handy feature. It's just too bad it's on a damn microsux product. please put it in firefox. Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7 Nick Crain wrote: > Name: Nick Crain > Email: n.crain_at_r...

please please please
Name: Product: Firefox Summary: please please please Comments: could you please resolve this crashing. the browsers crashes so often... I'm watching streaming video and it crashes in the middle of it... which costs me. I don't want to exceed me bandwith with friggin rogers. they're a pain. Browser Details: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you mus...

VS.NET Web App messing up form authentication? Help, please?
Does anyone know of any problems with creating a VS.NET Web App in a forms authenticated subfolder? I created a Web App "pics" with VS.NET as a subfolder of wwwroot, and the Request.ServerVariables("AUTH_USER") is always blank on all the pages in this subfolder wwwroot/pics. I deleted the VS.NET premade Web.Config file so that there is only the one file at wwwroot, but that didn’t help. Are there any other files created by VS.NET that could be messing this up? I made other ASPX subfolders outside of VS.NET and they all continue the session just fine, it's like this ...

Desperate Visual Studio .NET problem with Web Forms, please help
Hi, I've posted in the past about this problem and got no response, but now I'm desperate so have to try again. In Visual Studio .NET 2003, with .NET Framework 1.1, all web form controls (in fact all controls in the toolbar) are disabled. I create a webform.aspx page, I am in design view, but when I go to the "web forms" toolbar, I cannot drag anything to the page. I solved this last time by completely wiping my drive and spending three days reinstalling and updating everything. Everything in Visual Studio worked as expected for a few days, and now yet again everything is disabled. Can s...

Funny character being added instead of spaces in .net web forms...please help
Hi,in all of my asp.net pages I have the following html code:&nbsp;&lt;TD class=padding colSpan=2 height=23&gt;&lt;div align="center"&gt;&lt;A &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; href="#"&gt;Privacy Policy&lt;/A&gt; »&lt;a href="#"&gt; Terms of Use&lt;/a&gt;&lt;/div&gt;&lt;/TD&gt;on my default.aspx page, this gets displayed as: Privacy Policy » Terms of Useand the code isPrivacy Policy » Terms of UseCan ...

LDAP Request Help
My head is about to fly off my neck and shoot through the ceiling! Ive been trying to make the following code work for weeks, and I cannot figure it out. The code is located at this website: http://v5.beta.docutek.com/eres/custom/fresnoLDAP.aspx. Everytime I try to run this sub I get the following error: "Unknown error (0x80005000) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.InteropServic...

Web resources about - What is this all about? Please please help! - asp.net.web-forms

President Obama Holds a Press Conference
The White House ***Live coverage of this event has concluded. Drag the counter along the timeline below the stream to replay. The full video ...

Martin Shkreli’s Arrest Causes A Stir In ‘Big Pharma’ Game
Since the former CEO of Turing Pharmaceuticals Martin Shkreli posted a $5-million dollar bail, many organizations with whom he had a business ...

Target Rumored To Be Working On Own Mobile Payments Service
A couple of weeks ago, Walmart announced Walmart Pay . It was rather surprising but given that Walmart was one of the larger retailers to not ...

Obama meets privately in San Bernardino with terror victims' families
USA TODAY Obama meets privately in San Bernardino with terror victims' families USA TODAY President Obama met quietly with the families of ...

By George! Charlotte is just like her mummy: Adorably happy family portrait show how little princess ...
An informal family portrait (right) of Kate (pictured at age one bottom left) and Wills (top left as a two-year-old) with their two children ...

‘Let Me Finish What I’m Saying’: Greta Confronts Cruz Over Past Immigration Position
After this week’s GOP debate, there was a renewed focus in the media over Ted Cruz ‘s past immigration positions. Back in 2013, he attempted ...

Jason Day’s wife released from hospital after LeBron James crash landing - Sport - The Guardian
Ellie Day, the wife of the US PGA champion Jason Day, has been released from hospital after being on the receiving end of a LeBron James crash ...

Nirbhaya case: Unlawful to keep juvenile convict in jail, says Delhi High Court
BJP leader Subramanian Swamy had filed a PIL before the High Court to extend the stay of the juvenile.

Virginia district cancels school over Islamic lesson anger
CNN Virginia district cancels school over Islamic lesson anger The Denver Post STAUNTON, Va. — A rural Virginia school district canceled classes ...

Apple's Tim Cook says tax avoidance criticism is 'political crap'
Apple and other tech companies have been criticised for using complex cross-border accounting measures to transfer profits to low tax jurisdictions ...

Resources last updated: 12/19/2015 8:23:01 AM