Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


My asp.net button is still not enabled even when I set it to enabled

Posted on 2009-12-23
Medium Priority
Last Modified: 2012-05-08
Hi, I'm using vs2008, .net
The breakpoint is set at this loc and it's executed but the update button is still not ablled.  How can I address this?  thank you.
both buttons are not abled even code is executed and I can see the property is set to be abled.  I refresh the page again and nothing changes.  

Protected Sub gvWorkingDocs_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvWorkingDocs.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            ' Get the DataKey Value of the grid row
            Dim newFileName As String
            newFileName = gvWorkingDocs.DataKeys(e.Row.RowIndex).Value.ToString()
            Dim updateButton As System.Web.UI.WebControls.Button
            Dim editButton As System.Web.UI.WebControls.Button

            'If a match is found then the doc is checked out
            For i As Integer = 0 To dsDocsLogs.Tables(0).Rows.Count - 1
                If dsDocsLogs.Tables(0).Rows(i)("NewFileName").ToString() = newFileName Then
                    'Fill in the status info
                    e.Row.Cells(8).Text = "Checked out by " + dsDocsLogs.Tables(0).Rows(i)("userName").ToString() & _
                    " @" + dsDocsLogs.Tables(0).Rows(i)("dateTime").ToString()

                    'Enable or Disable Update and Edit button
                    If dsDocsLogs.Tables(0).Rows(i)("userId").ToString() = userId Then
                        updateButton = CType(e.Row.FindControl("editWorkingDoc"), System.Web.UI.WebControls.Button)
                        updateButton.Enabled = True
                    Else 'else, disable the Edit button
                        editButton = CType(e.Row.FindControl("btnUpdate"), System.Web.UI.WebControls.Button)
                        editButton.Enabled = False
                    End If
                End If

        End If
    End Sub

Open in new window

Question by:lapucca
  • 3
  • 2

Author Comment

ID: 26115604
Here is the code for the gridview
<asp:GridView ID="gvWorkingDocs" runat="server" AutoGenerateColumns="False" 
                DataKeyNames="NewFileName" DataSourceID="SqlDataSource1" CellPadding="4" 
                ForeColor="Black" BackColor="#AFE9CC" BorderColor="Black" 
                BorderStyle="Solid" BorderWidth="1px" style="margin-left: 0px" 
                    AllowSorting="True" AllowPaging="True" >
                <RowStyle BackColor="#FFFF99" ForeColor="#000000" HorizontalAlign="Left" 
                    BorderStyle="Ridge" />
                    <asp:BoundField DataField="gcrcNumber" HeaderText="GCRC" ReadOnly="True" 
                        SortExpression="gcrcNumber" Visible="False" />
                    <asp:BoundField DataField="IRBNum" HeaderText="IRB #" ReadOnly="True" 
                        SortExpression="IRBNum" Visible="False" />
                    <asp:BoundField DataField="CtuApp_ID" HeaderText="Application ID" 
                        SortExpression="CtuApp_ID" Visible="False" />
                    <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" />
                    <asp:BoundField DataField="NewFileName" HeaderText="FileName" 
                        SortExpression="NewFileName" Visible="False" />
                    <asp:BoundField DataField="OriginalFileName" HeaderText="File Name" 
                        SortExpression="OriginalFileName" />
                    <asp:BoundField DataField="Date" HeaderText="Modified Date" 
                        SortExpression="Date" ItemStyle-Wrap="False" ><ItemStyle Wrap="False"></ItemStyle>
                    <asp:BoundField DataField="LongName" HeaderText="LongName" ReadOnly="True" 
                        SortExpression="LongName" Visible="False" />
                    <asp:BoundField DataField="Status" HeaderText="Status" 
                        SortExpression="Status" />                                        
                            <asp:button ID="editWorkingDoc" runat="server" CommandName="editDoc" 
                            CommandArgument='<%# (CType(Container, GridViewRow).RowIndex).ToString() + "," + Eval("NewFileName") + "," + Eval("DocPath") %>'                   
                            Text="Edit" Enabled="True"></asp:button>                        
                            <asp:button id="btnUpdate" runat="server" commandName="selectToUpdate" 
                            CommandArgument='<%# Eval("NewFileName") %>' text="Update" Enabled="False"/>

                <FooterStyle BackColor="#EEEEE0" Font-Bold="True" ForeColor="#000000" BorderStyle="Solid" BorderWidth="1px" BorderColor="Black" />
                <PagerStyle BackColor="#ffffff" ForeColor="#000000" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#EEEEE0" Font-Bold="True" ForeColor="Black" BorderWidth="1px" />
                <HeaderStyle BackColor="#CCFFCC" Font-Bold="True" ForeColor="Black" 
                    BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" />
                <EditRowStyle BackColor="#AFE9CC" />
                <AlternatingRowStyle BackColor="#FFFFCC" BorderWidth="1px" BorderStyle="Solid" 
                    BorderColor="Black" />

Open in new window

LVL 36

Expert Comment

by:Miguel Oz
ID: 26115959
Can you put breakpoints at line 17 in you question code snippet?
Tell me what these values are when program stop in the breakpoint:

If not hit in the breakpoint try line 11. you may have a problem when comparing the strings. (eg. case, match exactly)

Accepted Solution

AsishRaj earned 2000 total points
ID: 26116030

updateButton = CType(e.Row.FindControl("editWorkingDoc"), System.Web.UI.WebControls.Button)

Shouldnt that be

updateButton = CType(e.Row.FindControl("btnUpdate"), System.Web.UI.WebControls.Button)

And samething for EditButton
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 26116049
These are hit alright.  I copy the value from debug anyway just to show you.  Yeah, the loc is definitly executed for setting the updateButton to Enabled but it still shows up disabled.  Thanks.

            dsDocsLogs.Tables(0).Rows(i)("NewFileName").ToString()       "300-4A-09-1CTU_HS-09-00489_10-22-09-10292009135102.doc"      String

            newFileName      "300-4A-09-1CTU_HS-09-00489_10-22-09-10292009135102.doc"      String

            dsDocsLogs.Tables(0).Rows(i)("userId").ToString()      "AlphaDavis"      String

userId = "AlphaDavis"

Author Closing Comment

ID: 31669603
Good catch!  Yeah, the stupid bug kept me working on this for like a couple hours already!  Thank you!

Expert Comment

ID: 26116094
Really Glad that i was able to help you out.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question