Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Gridview looping through records in aaspx page...

Posted on 2012-04-05
3
Medium Priority
?
317 Views
Last Modified: 2012-06-27
Hi,

On my aspx page I'm binding datasource to a datagrid and set the AutoGenerateColumns="false" so I could construct the column as i wish. This what I done:

<Columns>
            <asp:TemplateField HeaderText="Exam Sit" runat="server">
                             <ItemTemplate>
                                 <asp:CheckBox  ID="chkExamsit" runat="server" Text="" />
                            </ItemTemplate>
             </asp:TemplateField>
            <asp:TemplateField HeaderText="Exam Code" runat="server">
                             <ItemTemplate>
                                <asp:Label ID="lblExamCode" runat="server" Text='<%# ((ExamsDisplay)Container.DataItem).ExamCode %>'></asp:Label>
                            </ItemTemplate>
             </asp:TemplateField>
             <asp:TemplateField HeaderText="Description" runat="server">
                             <ItemTemplate>
                                <asp:Label ID="lblDescription" runat="server" Text='<%# ((ExamsDisplay)Container.DataItem).Description %>'></asp:Label>
                            </ItemTemplate>
            </asp:TemplateField>
   
             <asp:TemplateField HeaderText="Duration" runat="server">
                             <ItemTemplate>
                                <asp:Label ID="lblDuration" runat="server" Text='<%# ((ExamsDisplay)Container.DataItem).Duration %>'></asp:Label>
                            </ItemTemplate>
            </asp:TemplateField>
           
             <asp:TemplateField HeaderText="Requested Date" runat="server">
                             <ItemTemplate>
                                <asp:DropDownList ID="ddlRequestedDate" DataSourceID="xmlExamLevelDates" DataMember="ExamLevelDate" DataTextField="Date"  Width="100" runat="server" > </asp:DropDownList>
                            </ItemTemplate>
            </asp:TemplateField>
           
             <asp:TemplateField HeaderText="Requested Venue" runat="server">
                             <ItemTemplate>
                                <asp:DropDownList ID="ddlRequestedVenue" Width="100" runat="server" > </asp:DropDownList>
                            </ItemTemplate>
            </asp:TemplateField>
         
           
             <asp:TemplateField HeaderText="Exam Result" runat="server">
                             <ItemTemplate>
                                <asp:TextBox ID="txtExamResult" runat="server" Width="75" Text='<%# ((ExamsDisplay)Container.DataItem).Result %>'></asp:TextBox>
                            </ItemTemplate>
            </asp:TemplateField>
   
             <asp:TemplateField HeaderText="Confirmed Date" runat="server">
                             <ItemTemplate>
                                <asp:TextBox ID="txtConfirmedDate" runat="server" CssClass="datepicker" Text='<%# ((ExamsDisplay)Container.DataItem).ConfirmedExamDate %>'></asp:TextBox>
                            </ItemTemplate>
            </asp:TemplateField>
   
             <asp:TemplateField HeaderText="Confirmed Venue" runat="server">
                             <ItemTemplate>
                                <asp:DropDownList ID="ddlConfirmedVenue" Width="100" runat="server" > </asp:DropDownList>
                            </ItemTemplate>
            </asp:TemplateField>

Now I want this data to be sent it to a data store for storage. How do I loop through the records in a gridview control that has template column rather than bound column.

Can someone help me do this plaese.

Thanks!

Regards - Raj
0
Comment
Question by:ube100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Expert Comment

by:Kamal Khaleefa
ID: 37820751
hi

each time you have to change the data type for each coloum

for example:
    Dim chkExamsit As CheckBox = CType(GridView1.Rows(i).Cells(0).FindControl("chkExamsit"), CheckBox)
    Dim lblExamCodeAs label= CType(GridView1.Rows(i).Cells(1).FindControl("lblExamCode"), label)
.
.....



make a for statement and search each record
Ex:
  For i As Integer = 0 To GridView1.Rows.Count - 1
                Dim chkDelete As CheckBox = CType(GridView1.Rows(i).Cells(0).FindControl("chkContractor"), CheckBox)
                If Not chkDelete Is Nothing Then
                    If chkDelete.Checked Then

                     

                       ' do what u want

                           

                        End If
                    End If
                End If
            Next
0
 

Author Comment

by:ube100
ID: 37820785
Hi,

  Dim chkDelete As CheckBox = CType(GridView1.Rows(i).Cells(0).FindControl

What is Cells(0) represent here? I believe, the position of the column in the row?
0
 
LVL 16

Accepted Solution

by:
Kamal Khaleefa earned 2000 total points
ID: 37822970
thats correct it is the position of the column in the row
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

618 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