|
-
Sep 7th, 2006, 09:15 AM
#1
Thread Starter
Fanatic Member
gridView RowEditing
I have the follwoing function which loops through 3 datagrids on my page and should disable all other edit buttons when one edit button is clicked.
VB Code:
Protected Sub DisableEdit()
Dim c As Control
Dim content As ContentPlaceHolder
content = Page.Master.FindControl("contentplaceholder1")
Dim grid As GridView
Dim frow As GridViewRow
For Each c In content.Controls
If c.GetType() Is GetType(GridView) Then
grid = CType(c, GridView)
For Each frow In grid.Rows
If (frow.RowType = DataControlRowType.DataRow) Then
If Not frow.RowState = DataControlRowState.Edit Then
Dim btnEdit As LinkButton = frow.Cells(8).Controls(0)
btnEdit.Enabled = False
End If
End If
Next
End If
Next
End Sub
I call this on the RowEditing of each gridview, unfortunately RowEditing Occurs when a row's Edit button is clicked, but before the GridView control enters edit mode. Which means it turns them all to false but re-binds the gridview that called the fucntion, which in turn renders all fo the controls visible.
Does anyone know of a workaround for this, or the correct event to use that will fire after the control enters edit mode
-
Sep 8th, 2006, 09:18 AM
#2
Thread Starter
Fanatic Member
Re: gridView RowEditing
I have decided to write a seperate function that will be called on page_prerendercomplete. This is the code:
VB Code:
Protected Sub DisableEdits()
Dim c As Control
Dim content As ContentPlaceHolder
content = Page.Master.FindControl("ContentPlaceHolder1")
Dim EditOn As Boolean = False
Dim grid As GridView
Dim frow As GridViewRow
For Each c In content.Controls
If c.GetType() Is GetType(GridView) Then
grid = CType(c, GridView)
For Each frow In grid.Rows
If (frow.RowType = DataControlRowType.DataRow) Then
If frow.RowState = DataControlRowState.Edit Then
EditOn = True
End If
End If
Next
End If
Next
If EditOn = True Then
For Each c In content.Controls
If c.GetType() Is GetType(GridView) Then
grid = CType(c, GridView)
For Each frow In grid.Rows
If (frow.RowType = DataControlRowType.DataRow) Then
If Not frow.RowState = DataControlRowState.Edit Then
Dim btnEdit As LinkButton = frow.Cells(9).Controls(0)
btnEdit.Enabled = False
End If
End If
Next
End If
Next
Else
For Each c In content.Controls
If c.GetType() Is GetType(GridView) Then
grid = CType(c, GridView)
For Each frow In grid.Rows
If (frow.RowType = DataControlRowType.DataRow) Then
'If Not User.IsInRole(frow.DataItem("Number").ToString) Then
Dim btnEdit As LinkButton = frow.Cells(9).Controls(0)
btnEdit.Enabled = True
'End If
End If
Next
End If
Next
End If
End Sub
this loops through all 3 of my gridviews, if any of the command buttons are set to edit, its turns a boolean to false, whch in turn disables all other edit buttons. If boolean remains true all edit buttons are set to active.
This works but I am getting a strange problem, if i click the first edit button the others disable, then when i click 'save' or 'cancel' the others are activated again which works perfectly.
However the second link button doesnt work, then the third one does then the fourth one doesnt etc.
any clues?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|