View Single Post
  #1 (permalink)  
Old August 25th, 2009, 08:51 PM
phuc2583 phuc2583 is offline
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