Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GridView inside a Repeater?

Status
Not open for further replies.

elhaix

Programmer
Jul 31, 2006
115
CA

Hi All,

I'm having an issue with a GridView inside a repeater.

I've got the grid successfully bound to the repeater row, so in my test case, I have two grids that show up - one with two rows, the other with one.

The issue is that when I'm performing processing on cell data in a given row, it is also reflected in the other grid!

I know is about having to grab the right grid instance and making a change to that one, but I'm stuck on this.

Here's the code:

Code:
    Protected Sub TestGrid_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
        ' because the grid resides inside the Repeater's ItemTemplate, it must be referenced as follows:
        Dim TestGrid As GridView = CType(RptApprovals.Controls(0).FindControl("TestGrid"), GridView)
                    e.Row.Cells(6).Text = String.Format("{0:c}", salary)
.
.
.

The issue is that updating cell 6 does so on both grids that are displayed. The data must be unique per grid instance.

Thanks.
 
The answer lies in sender:

GridView gv = (GridView)sender;

Dim thisUserID = CType(sender, GridView).DataKeys(e.Row.DataItemIndex).Item("EmployeeUserID")
Dim thisEncryptedSalary = CType(sender, GridView).DataKeys(e.Row.DataItemIndex).Item("AnnualSalaryEncrypted")


Next issue - can't get the Update/CancelEdit events to fire. Something happens, but the event delegate methods are never touched.

Clues?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top