Link to home
Start Free TrialLog in
Avatar of lapucca
lapucca

asked on

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

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
            Next

        End If
    End Sub

Open in new window

Avatar of lapucca
lapucca

ASKER

Here is the code for the gridview
<asp:GridView ID="gvWorkingDocs" runat="server" AutoGenerateColumns="False" 
                onrowcommand="gvWorkingDocs_RowCommand"
                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" />
                <Columns>
                    <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>
                    <asp:BoundField DataField="LongName" HeaderText="LongName" ReadOnly="True" 
                        SortExpression="LongName" Visible="False" />
                    <asp:BoundField DataField="Status" HeaderText="Status" 
                        SortExpression="Status" />                                        
                    
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:button ID="editWorkingDoc" runat="server" CommandName="editDoc" 
                            CommandArgument='<%# (CType(Container, GridViewRow).RowIndex).ToString() + "," + Eval("NewFileName") + "," + Eval("DocPath") %>'                   
                            Text="Edit" Enabled="True"></asp:button>                        
                        </ItemTemplate>
                    </asp:TemplateField>
                      
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:button id="btnUpdate" runat="server" commandName="selectToUpdate" 
                            CommandArgument='<%# Eval("NewFileName") %>' text="Update" Enabled="False"/>
                        </ItemTemplate>
                    </asp:TemplateField>                     

                </Columns>
                <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" />
            </asp:GridView>

Open in new window

Avatar of Miguel Oz
Can you put breakpoints at line 17 in you question code snippet?
Tell me what these values are when program stop in the breakpoint:
dsDocsLogs.Tables(0).Rows(i)("NewFileName").ToString()
newFileName
dsDocsLogs.Tables(0).Rows(i)("userId").ToString()
userId

If not hit in the breakpoint try line 11. you may have a problem when comparing the strings. (eg. case, match exactly)
ASKER CERTIFIED SOLUTION
Avatar of AsishRaj
AsishRaj
Flag of Fiji image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lapucca

ASKER

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"
Avatar of lapucca

ASKER

Good catch!  Yeah, the stupid bug kept me working on this for like a couple hours already!  Thank you!
Really Glad that i was able to help you out.