Solved

Gridview GridViewRow is empty

Posted on 2007-11-26
4
849 Views
Last Modified: 2013-11-07
Hi Experts

I have a Gridview with a template Col with a check box, what I want to to (and Am doing sucsesssfully with a test page and I GV) is detect which rows have a tick on post back.

My page has 3 GV's each with a unique ID, when I tick any of the boxes and hit a go btn the GridViewRow is empty. I have a  test page with 1 GV and it works OK, so the problem appears to be around the multi GV's I can post my code if required, but it does work.

Has anyone seen this behaviour before and found a solution, or is it me?

Andy
0
Comment
Question by:Andy Green
[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
  • 2
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 250 total points
ID: 20348940
on go btn Click bind the data to all the grid views again
0
 
LVL 3

Author Comment

by:Andy Green
ID: 20348963
I think I tried that, and it cleared the selection, but just to make sure I'll try again.

Andy
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 20348968
If Possible post your code , so that its easy to understand the problem
0
 
LVL 3

Author Comment

by:Andy Green
ID: 20349032
Hi

Re bound the data and whilst GridViewRows now have data, the selected rows have been cleared.

What I dont understand is the code works fine with 1 GV but not multiple.

The code pages are quite large, but this is my template section and code behind for  the working one, which is identical to the faulty one. I think I'm loosing data on postback some where but cant find it. If all else fails I can capture the clicks on the client and persist those.

                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:CheckBox ID="selectQuestion"  runat="server" />
                            </ItemTemplate>
                        </asp:TemplateField>

    Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 
        For Each row As GridViewRow In gvAvailableQuestions.Rows

            Dim cb As CheckBox = row.FindControl("selectQuestion")
            If cb IsNot Nothing AndAlso cb.Checked Then
             
                Dim QuestionID As Integer = _
                    Convert.ToInt32(gvAvailableQuestions.DataKeys(row.RowIndex).Value)

                lbldebug.Text &= String.Format("You Selected  {0}<br />", QuestionID)

            End If
        Next

    End Sub

0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

737 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