disable a linkbutton in gridview

disable a linkbutton in gridview

Page 1 of 1

3 Replies - 14282 Views - Last Post: 09 September 2010 - 12:52 PM Rate Topic: -----

#1 Best123   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 05-August 10

disable a linkbutton in gridview

Posted 09 September 2010 - 06:45 AM

I have a grid view with each row as a link button. When I click on the row, some data parsing process takes place. The grid refreshes itself at a regular interval. I want to disable the link when it is clicked once, so that the user gets to know that row has been processed already and does not click it again, until the grid refreshes itself and the row disappears.
I am copying my gridview code below. Please give me some idea on how to disable the link button on that row.

 <td rowspan = "4" valign = "top" >
            <asp:Label ID="gvOrdersQueueLabel" runat="server" ></asp:Label><br />
             <asp:UpdatePanel runat="server" ID="updatePane1">
                <ContentTemplate>
                    <asp:GridView ID="gvOrdersQueue" runat="server" OnRowCommand = "ParseOrderMessage" EmptyDataText="No Cases Found"  BorderStyle = "Double" 
                    AlternatingRowStyle-BackColor="Beige" EnableViewState="false" AutoGenerateColumns="False"  HeaderStyle-Height = "20" RowStyle-Height = "20" AllowPaging ="true" 
                         PageSize = "20" OnPageIndexChanging="gridView_PageIndexChanging" PagerSettings-Mode = "NumericFirstLast"  Font-Size = "Small">
                        <Columns>                        
                <asp:TemplateField HeaderText="Message ID" ItemStyle-Wrap = "false">
                    <ItemTemplate>
                    <asp:Label ID="LblMsgID" runat="server" Text='<%# Eval("MessageID") %>' visible="false"></asp:Label>  
                    <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument ='<%# Eval("MessageID") +"|"+ Eval("FileName")%>' CommandName = "WriteORM" ><%# Eval("MessageID") %></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Date Time" ItemStyle-Wrap = "false">
                    <ItemTemplate>
                    <asp:LinkButton ID="LinkButton2" runat="server" CommandArgument ='<%# Eval("MessageID") +"|"+ Eval("FileName")%>' CommandName = "WriteORM" ><%# Eval("MessageDateTime") %></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="File Name" ItemStyle-Wrap = "false">
                    <ItemTemplate>
                    <asp:LinkButton ID="LinkButton3" runat="server" CommandArgument ='<%# Eval("MessageID") +"|"+ Eval("FileName")%>' CommandName = "WriteORM" ><%# Eval("FileName") %></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>                         
                        </Columns>
                    </asp:GridView>
                    <asp:Timer ID="Timer1" runat="server" OnTick="Timer_Tick"> </asp:Timer>
                </ContentTemplate>
                </asp:UpdatePanel>   
        </td>     



Is This A Good Question/Topic? 0
  • +

Replies To: disable a linkbutton in gridview

#2 Frinavale   User is offline

  • D.I.C Addict
  • member icon

Reputation: 205
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: disable a linkbutton in gridview

Posted 09 September 2010 - 10:08 AM

In your data source, add a field that will indicate if the record/row should be disabled.
You can then bind the Enabled property for the link button to that field.

So, when the user clicks the LinkButton, set the field to indicate that the record should be disabled. That way the link will be disabled upon returning to the browser.

This solution is server side oriented.
You can implement a client side solution for this but it's more complicated.

-Frinny
Was This Post Helpful? 0
  • +
  • -

#3 Best123   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 05-August 10

Re: disable a linkbutton in gridview

Posted 09 September 2010 - 11:53 AM

View PostFrinavale, on 09 September 2010 - 09:08 AM, said:

In your data source, add a field that will indicate if the record/row should be disabled.
You can then bind the Enabled property for the link button to that field.

So, when the user clicks the LinkButton, set the field to indicate that the record should be disabled. That way the link will be disabled upon returning to the browser.

This solution is server side oriented.
You can implement a client side solution for this but it's more complicated.

-Frinny

That will disable it when the processing is done, the disable field is populated and the grid refreshes. In that case the row disappears any way. I want it to be disabled as soon as it is clicked so the user does not click it twice (to avoid multiple clicks). The processing takes about 10 seconds to finish.
Was This Post Helpful? 0
  • +
  • -

#4 Frinavale   User is offline

  • D.I.C Addict
  • member icon

Reputation: 205
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: disable a linkbutton in gridview

Posted 09 September 2010 - 12:52 PM

Ok, so you're looking for a client-side solution.

This is going to involve Javascript.

You'll have to implement a Javascript method that will disable the link after the user clicks on it. Be careful about using the enabled property because if you disable a control using Javascript sometimes it doesn't postback to the server...or it does post back to the server but the information about the event is lost (because the server detects the control is disabled)...or worse the page doesn't validate.

You could try the "disable" approach or you could add a reference to the link to an array when it is clicked...if the link exists in the array already, then display an alert informing the user that the record they selected is already being processed.

Or...since you can only process one at a time (are you using AJAX??), it might be a good idea to put a <div> over top of the Grid when it is being processed to prevent the user from interacting with it while it is processing (you know the kind that are half visible) and also display a "processing" message to the user.

There are a lot of options.

-Frinny

This post has been edited by Frinavale: 09 September 2010 - 12:53 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1