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.