Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

reference gridview dataitem in rowediting event

Posted on 2008-06-18
6
Medium Priority
?
2,779 Views
Last Modified: 2013-11-07
Ok I have a gridview bound to a sql datasource, on of the fields it returns is a pipe delimited string.
I use a template control with a label in the item template that sends the string to a function that splits it and displays a ul.

now in the edit item template i have a checkbox list. When the user clicks the edit button, I want to reference the control and the dataitem, loop through it and select certain checkboxes.

I can reference the checkbox list fine, but how can i get the dataitem?
Or is there a better way to do this?
0
Comment
Question by:Dustin Hopkins
  • 3
  • 2
6 Comments
 
LVL 22

Expert Comment

by:prairiedog
ID: 21822089
>>>I want to reference the control and the dataitem,
Which control do you want to reference? The label?
0
 
LVL 14

Author Comment

by:Dustin Hopkins
ID: 21826454
No i want to reference the checkboxlist, did that with no problem.

Its the dataitem thats giving me the problem, i tried using the eval.databinder method like you would use in the onrowdatabound event, but its throwing object reference not set to an instance of the object.
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 21826527
Can you post the code that you reference the checkboxlist and the code you use to get the dataitem?
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 14

Accepted Solution

by:
Dustin Hopkins earned 0 total points
ID: 21828328
Ok, I got it working, I just had to add this to my datarowbound event
If e.Row.RowState = DataControlRowState.Edit Or _
 (e.Row.RowState = (DataControlRowState.Alternate Or DataControlRowState.Edit)) Then
 
            Dim cbl As CheckBoxList = CType(e.Row.FindControl("cblComp"), CheckBoxList)
            If DataBinder.Eval(e.Row.DataItem, "reqComp").ToString() <> "" Then
                Dim traincomp() As String = DataBinder.Eval(e.Row.DataItem, "ReqComp").ToString.Split("|")
                For Each s As String In traincomp
                    cbl.Items.FindByValue(s).Selected = True
                Next
            End If
        End If

Open in new window

0
 
LVL 10

Expert Comment

by:Smart_Man
ID: 22590835
do you mean to access the gridview.rowediting event ?

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowediting.aspx

waiting for your reply
0
 
LVL 14

Author Comment

by:Dustin Hopkins
ID: 22592269
No, I was having problems referencing the dataitem associtated with a row during the rowediting event. I didn't realize that that was done in the rowdatabound event. As the row rebinds when switching to an editing view. Basically i was storing a string of data in a single db column, seperated by pipes. Such as "one|two|three". Then I took this and broke it down and used it to fill a checkboxlist. Thanks though.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question