Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Professionals
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 25th, 2009, 08:51 PM
Authorized User
Join Date: Dec 2007
Location: , , Vietnam.
Posts: 59
Thanks: 9
Thanked 0 Times in 0 Posts
Post Do not get value from GridViewRow

Hello everybody

I have tried my best to get value from the Grid view but not successful.
Here is the my code. when i debug ,it ignore "For Each" statement.
Can you give me your ideal about the code behind below.
Function Booking_DetailAdd2() As String
Dim kq As String = ""
For Each gvr As GridViewRow In Me.gvRoomType.Rows
Dim cb As CheckBox = CType(gvr.FindControl("cbkRoomName"), CheckBox)
Dim cbSingle As CheckBox = CType(gvr.FindControl("cbkSingleP"), CheckBox)
Dim cbDouble As CheckBox = CType(gvr.FindControl("cbkDoubleP"), CheckBox)
Dim cbTriple As CheckBox = CType(gvr.FindControl("cbkTripleP"), CheckBox)
If cb.Checked Then
kq = "<hr><br>Room Type : " & cb.Text & _
"<br>Quantity Room:" & CType(gvr.FindControl("cbQuantityRoom"), DropDownList).SelectedValue
If cbSingle.Checked Then
kq &= "<br> Single Room : $" & CType(gvr.FindControl("cbkSingleP"), CheckBox).Text
End If
If cbDouble.Checked Then
kq &= "<br> Double Room : $" & CType(gvr.FindControl("cbkDoubleP"), CheckBox).Text
End If
If cbTriple.Checked Then
kq &= "<br> Triple Room : $" & CType(gvr.FindControl("cbkTripleP"), CheckBox).Text
End If
End If
Return kq
End Function
<asp:GridView ID="gvRoomType" runat="server" AutoGenerateColumns="False" CellPadding="5"
ForeColor="#333333" GridLines="None" HorizontalAlign="Center" Width="100%" DataKeyNames="RoomTypeID">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<asp:TemplateField HeaderText="Room Type">
<ItemStyle Width="240px" />
<asp:CheckBox ID="cbkRoomName" runat="server" Font-Bold="True" ForeColor="#400000"
Text='<%# Bind("RoomTypeName") %>' /><br />

<HeaderStyle HorizontalAlign="Left" Height="25px" />
<asp:TemplateField HeaderText="Quantity Room">
<ItemStyle Width="100px" Wrap="False" HorizontalAlign="Center" />
<asp:DropDownList ID="cbQuantityRoom" runat="server" Width="40px">
<HeaderStyle HorizontalAlign="Center" Width="100px" />
<asp:TemplateField HeaderText="Single">
<ItemStyle HorizontalAlign="Left" Width="100px" />
<HeaderStyle HorizontalAlign="Center" />
<asp:CheckBox ID="cbkSingleP" runat="server" Font-Bold="False" ForeColor="#000040"
Text='<%# Bind("SinglePrice") %>' />
<asp:TemplateField HeaderText="Double">
<ItemStyle HorizontalAlign="Left" Width="100px" Wrap="False" />
<HeaderStyle HorizontalAlign="Center" Width="50px" />
<asp:CheckBox ID="cbkDoubleP" runat="server" Font-Bold="False" ForeColor="#000040"
Text='<%# Bind("DoublePrice") %>' />
<asp:TemplateField HeaderText="Triple">
<ItemStyle HorizontalAlign="Left" Width="100px" />
<HeaderStyle HorizontalAlign="Center" Width="50px" />
<asp:CheckBox ID="cbkTripleP" runat="server" Font-Bold="False" ForeColor="#000040"
Text='<%# Bind("TriplePrice") %>' />
<asp:TextBox ID="txtRoomRequest" runat="server" Visible="False"></asp:TextBox>
<SelectedRowStyle BackColor="#D1DDF1" ForeColor="#333333" Font-Bold="True" />
<PagerStyle BackColor="#99CCFF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#99CCFF" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />

I think it is a mistake on that
So, you can help me find out the solve
Best regards,
Phuc Hoang

Last edited by phuc2583; August 25th, 2009 at 09:21 PM.. Reason: Lack of information
  #2 (permalink)  
Old August 26th, 2009, 07:56 AM
Authorized User
Join Date: Mar 2008
Location: Delhi
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to myself.panku

hi Phuc

Could you plesae provide me ur data source as a XML file so that I can bind gvRoomType grid with that datasource and will be able to dedug your code.

I just need 2 as an XML form , because without that I will have to create my own data source with the prooper header you have used inside HTML.

It could create problem.
either you can mail that XML file into myself.panku@gmail.com or describe the headers of your data source here itself.

-Pankaj Bahuguna
  #3 (permalink)  
Old August 31st, 2009, 01:30 AM
Authorized User
Join Date: Dec 2007
Location: , , Vietnam.
Posts: 59
Thanks: 9
Thanked 0 Times in 0 Posts

I have found out it. The only way that is you do not use EnableViewState="false" on the master page.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add gridviewrow in databound dlanglois ASP.NET 2.0 Basics 1 December 17th, 2008 08:41 AM
extra column based on data in gridviewrow edwin.debrouwere ASP.NET 1.0 and 1.1 Basics 1 October 13th, 2006 09:18 AM
extra column based on data in gridviewrow edwin.debrouwere ASP.NET 1.0 and 1.1 Professional 0 October 13th, 2006 09:08 AM

All times are GMT -4. The time now is 09:55 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.