Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

reference gridview dataitem in rowediting event

Posted on 2008-06-18
6
Medium Priority
?
2,768 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

618 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