Solved

Accessing records from an Unbound gridview

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

20 Experts available now in Live!

Get 1:1 Help Now