Solved

Accessing records from an Unbound gridview

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
creating a flowchart from an algorithm 5 30
Set cookies HttpOnly and Secure 4 114
SQL Login 17 41
C#  Radio button search for Date not DateTime 4 35
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now