Link to home
Create AccountLog in
Avatar of JT_SIRO

asked on

Get checked value from grid

Does anyone see anything wrong with my code here?  I'm simply trying to loop through an Obout data grid and see if the user checked each row or not.  When I step through the code, every checkbox comes back as false, weather it's actually checked or not.  Thanks-  

// aspx code
                  <cc1:Grid ID="gvTracks" runat="server" Width="100%" CallbackMode="true" 
                        Serialize="true" AllowAddingRecords="false" AllowPaging="false" ShowFooter="false" PageSize="100"
                          FolderStyle="../OboutStyles/grid/style_2" AutoGenerateColumns="false">

                        <cc1:Column HeaderText="Add as Stem" Width="90" Index="1">
                            <TemplateSettings TemplateId="tmpStem"/>

                        <cc1:Column DataField="Filename" HeaderText="File Name" Index="2" Width="99%" Wrap="true"></cc1:Column>   
                        <cc1:GridTemplate runat="server" ID="tmpStem">
                                <asp:CheckBox ID="CheckBox1" runat="server" />

// Code behind
  //Loop through gridview rows to find checkbox and check whether it is checked or not 
        for (int i = 0; i < gvTracks.Rows.Count; i++)
            CheckBox chkCheck = (CheckBox)gvTracks.Rows[i].Cells[0].FindControl("CheckBox1");
            string strFilename = gvTracks.Rows[i].Cells[1].Text;    // Filename of the Stem         

            if (chkCheck.Checked)
// Do database stuff

Open in new window

Avatar of Kumaraswamy R
Kumaraswamy R
Flag of India image

Avatar of raja_ind82
Flag of India image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of JT_SIRO


Oh yea, I'm binding my grid in page load.  I missed that.  How should I get the button to fire first?  My grid is populated with a list of files in a specified folder.  Should I make that binding process it's own function, not in Page_Load?  Thanks -
Avatar of JT_SIRO


Ignore my response - I'm not feeling well and missed the obvious.  I got it now, thanks!
Avatar of JT_SIRO


Actually, I'm still stuck on this.  I moved my binding code into an If !IsPostback, and checked boxes are still not showing up as checked.  I'm building the grid rows dynamically in my code behind but am adding the check boxes in the aspx grid columns.  Could this have something to do with it?