Solved

Accessing records from an Unbound gridview

Posted on 2006-10-25
3
577 Views
Last Modified: 2012-06-21
1) I have a gridview which I bind dynamically in PageLoad by getting a dataset from an oracle stored procedure.
==============================================>
DataSet ds = new DataSet();  
ds = DBManager.getList();

DataView dv = new DataView(ds.Tables[0]);
        dgView.PageIndex = 0;
        dgView.DataSource = dv;
        dgView.DataBind();
        Session.Add(Constants.DATAVIEW_TRADES, dv);

===============================================>
2) The grid view has a checkbox column for each row, the user can select (check) multiple rows and then hit the submit button, which has a onclick event.

 <asp:GridView ID="dgView" runat="server" DataKeyNames="CONFIRM_UUID" EnableViewState="true"   CssClass="align: top" RowStyle-Font-Size="XX-Small" Font-Size="XX-Small"
                                    AlternatingRowStyle-BackColor="LightSkyBlue" AllowPaging="True" Width="1100px" AutoGenerateColumns="False"
                                    AllowSorting="true"  EmptyDataRowStyle-Height="0" RowStyle-VerticalAlign="Top"  RowStyle-Height="4"
                                    OnPageIndexChanging="dgView_PageIndexChanging" AlternatingRowStyle-Height="5"   OnRowCommand="dg_RowCommand" OnSorting="dgView_Sorting">                                                                  
                                    <EmptyDataTemplate>
                                    <asp:Label runat="server"> There are no records found for the selected search criteria.
                                    </asp:Label>
                                    </EmptyDataTemplate>
                                    <EmptyDataRowStyle Height="5" BackColor="LightSteelBlue" />
                                        <Columns>                                          
                                              <asp:TemplateField  HeaderText="Release">
                                                <HeaderStyle   BackColor="BlanchedAlmond" />
                                                <ItemTemplate>
                                                    <asp:CheckBox ID="chkStatus"  Checked='<%#Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "CHECKED_STATUS"))%>'  Visible="true"  
                                                    Enabled='<%#Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "ENABLED_STATUS"))%>'  Font-Bold="true" runat="server" />                                                    
                                                </ItemTemplate>
                                            </asp:TemplateField>
===========================================================>

3) On the submit button click event, I need to retrieve all the rows that were checked on the gridview.
How can I do this with an unbounded gridview?
0
Comment
Question by:countrymeister
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
RossWilko earned 500 total points
ID: 17807258
Hi,

I believe this should be the sort of thing your looking for...  

  protected void Button1_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow dvItem in dgView.Rows)
        {
            if (dvItem.RowType == DataControlRowType.DataRow)
            {
                if (((CheckBox)dvItem.FindControl("chkStatus")).Checked)
                {
                    dvItem
                }

            }
        }
    }

cheers

RW
0
 
LVL 1

Author Comment

by:countrymeister
ID: 17808366
Hi ! RossWilko

I will try this first thing tomorrow morning, I left work a little early.
I will post my reply based on the solution you provided

Thanks
H
0
 
LVL 1

Author Comment

by:countrymeister
ID: 17813657
Works like a charm based on your reccomendation

Thanks, I do have another question extending on this solution which I hope you can help me.
I am going to add it as a new post.

Can I add a checkbox to the header of a checkbox column in a Grid View?
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

840 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