CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums



Zone: > Asp.Net Forum > general_asp.net.data_presentation_controls Tags:
Item Type: Date Entered: 6/9/2007 7:01:12 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 5 Views: 2695 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
6 Items, 1 Pages |< << Go >> >|
"ZAiNT" <>
NewsGroup User
disable select button inside gridview AFTER you click it?6/9/2007 7:01:12 PM

0

 How to achieve this?

"mbanavige" <>
NewsGroup User
Re: disable select button inside gridview AFTER you click it?6/9/2007 8:37:57 PM

-1

check this link to see if you can adapt the one click button technique to your select button

http://www.codeproject.com/useritems/oneclickbutton.asp

 


Mike Banavige
~~~~~~~~~~~~
Dont forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
"ZAiNT" <>
NewsGroup User
Re: disable select button inside gridview AFTER you click it?6/9/2007 8:44:07 PM

-1

tried that piece of code earlier. not exactly what im after.

i need the button to stay disabled after the postback. how do I do that?

thanks
 

"mbanavige" <>
NewsGroup User
Re: disable select button inside gridview AFTER you click it?6/9/2007 9:00:29 PM

-2

given a grid with the select button in the 1st column:

<asp:GridView ID="GridView1" runat="server">            
   <Columns>
     <asp:CommandField ButtonType="Button" ShowSelectButton="True" />
   </Columns>
</asp:GridView>
  

We can add a little code behind to enable/disable the select button in that 1st column:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Me.GridView1.DataSource = TestData.GetTestData
            Me.GridView1.DataBind()
        End If
    End Sub

    Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
        ' if we alread had a selected row, the select button would be disabled
        ' so we re-enable it
        If Not Me.GridView1.SelectedRow Is Nothing Then
            DirectCast(Me.GridView1.SelectedRow.Cells(0).Controls(0), Button).Enabled = True
        End If
    End Sub

    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
        'now that we've selected a new row, we will disable the select button.
        'in this example, the select button was the only control in the 1st column of the grid
        DirectCast(Me.GridView1.SelectedRow.Cells(0).Controls(0), Button).Enabled = False
    End Sub
 

 


Mike Banavige
~~~~~~~~~~~~
Dont forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
"ZAiNT" <>
NewsGroup User
Re: disable select button inside gridview AFTER you click it?6/9/2007 9:13:16 PM

-1

Perfect. Exactly what I was looking for! Thanks very much :]
"ZAiNT" <>
NewsGroup User
Re: disable select button inside gridview AFTER you click it?6/9/2007 9:37:22 PM

-1

 this works too. which solution is the most right one? i assume this one? thanks

 from msdn: Although the RowCommand event is raised when a button listed in the previous table is clicked, it is recommended that you use the events listed in the table for the operation.

CommandName value

Description

"Select"

Selects the current record. Raises the SelectedIndexChanging and SelectedIndexChanged events.


 

1        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
2 {
3 (this.GridView1.SelectedRow.Cells[0].Controls[0] as Button).Enabled = false;
4 }
5
6 protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
7 {
8 if (GridView1.SelectedRow != null)
9 {
10 (this.GridView1.SelectedRow.Cells[0].Controls[0] as Button).Enabled = true;
11 }
12 }
13
 
6 Items, 1 Pages |< << Go >> >|



Free Download:






   
  Privacy | Contact Us
All Times Are GMT