Solved

Accessing records from an Unbound gridview

Posted on 2006-10-25
3
578 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

730 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