Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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
Next
Return kq
End Function
-----------------------
HTML
<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" />
<Columns>
<asp:TemplateField HeaderText="Room Type">
<ItemStyle Width="240px" />
<ItemTemplate>
<asp:CheckBox ID="cbkRoomName" runat="server" Font-Bold="True" ForeColor="#400000"
Text='<%# Bind("RoomTypeName") %>' /><br />

</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" Height="25px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity Room">
<ItemStyle Width="100px" Wrap="False" HorizontalAlign="Center" />
<ItemTemplate>
<asp:DropDownList ID="cbQuantityRoom" runat="server" Width="40px">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Width="100px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Single">
<EditItemTemplate>
&nbsp;
</EditItemTemplate>
<ItemStyle HorizontalAlign="Left" Width="100px" />
<HeaderStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:CheckBox ID="cbkSingleP" runat="server" Font-Bold="False" ForeColor="#000040"
Text='<%# Bind("SinglePrice") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Double">
<ItemStyle HorizontalAlign="Left" Width="100px" Wrap="False" />
<HeaderStyle HorizontalAlign="Center" Width="50px" />
<ItemTemplate>
<asp:CheckBox ID="cbkDoubleP" runat="server" Font-Bold="False" ForeColor="#000040"
Text='<%# Bind("DoublePrice") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Triple">
<ItemStyle HorizontalAlign="Left" Width="100px" />
<HeaderStyle HorizontalAlign="Center" Width="50px" />
<ItemTemplate>
<asp:CheckBox ID="cbkTripleP" runat="server" Font-Bold="False" ForeColor="#000040"
Text='<%# Bind("TriplePrice") %>' />
<asp:TextBox ID="txtRoomRequest" runat="server" Visible="False"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<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" />
</asp:GridView>

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
Default

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.

Thanks
-PANKAJ
__________________
Thanks
-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
Default

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


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





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