0

Hello everyone! I wanna know If how will I get the values from the selected checkboxes of my datagridview, the values of the textboxes on the right and how will i put the selected values in a Session?

thanks in advance! heres the pic of my project.
http://i53.tinypic.com/2cz7z2o.jpg

Edited by piranha3d: n/a

3
Contributors
5
Replies
8
Views
6 Years
Discussion Span
Last Post by Sals
0

DataGridView is a winform control. Please post your code here so we can provide better help.

0

here's my code

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CssClass="gridstyle"
                                DataSourceID="AccessDataSource1" Font-Names="Calibri" Font-Size="14px" GridLines="None"
                                Width="500px" DataKeyNames="RoomCode">
                                <Columns>
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <center>
                                                <asp:CheckBox ID="CheckBox1" runat="server" />
                                            </center>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField Visible="False" DataField="RoomCode" HeaderText="Room Code" ReadOnly="True"
                                        SortExpression="RoomCode">
                                        <ItemStyle HorizontalAlign="Center" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="RoomName" HeaderText="Rooms" SortExpression="RoomName">
                                        <ItemStyle HorizontalAlign="Center" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="RoomNumberAvailable" HeaderText="No. of Available Rooms"
                                        ReadOnly="True" SortExpression="RoomNumberAvailable">
                                        <ItemStyle HorizontalAlign="Center" />
                                    </asp:BoundField>
                                    <asp:TemplateField>
                                        <HeaderTemplate>
                                            No of Rooms to Lodge
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <center>
                                                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                                            </center>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <PagerStyle ForeColor="#053769" />
                                <HeaderStyle BackColor="#E1E2FA" ForeColor="#053769" />
                            </asp:GridView>
                            <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/Blue Coral DB.mdb"
                                SelectCommand="SELECT * FROM RoomList"></asp:AccessDataSource>
0

here's my code

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CssClass="gridstyle"
                                DataSourceID="AccessDataSource1" Font-Names="Calibri" Font-Size="14px" GridLines="None"
                                Width="500px" DataKeyNames="RoomCode">
                                <Columns>
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <center>
                                                <asp:CheckBox ID="CheckBox1" runat="server" />
                                            </center>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField Visible="False" DataField="RoomCode" HeaderText="Room Code" ReadOnly="True"
                                        SortExpression="RoomCode">
                                        <ItemStyle HorizontalAlign="Center" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="RoomName" HeaderText="Rooms" SortExpression="RoomName">
                                        <ItemStyle HorizontalAlign="Center" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="RoomNumberAvailable" HeaderText="No. of Available Rooms"
                                        ReadOnly="True" SortExpression="RoomNumberAvailable">
                                        <ItemStyle HorizontalAlign="Center" />
                                    </asp:BoundField>
                                    <asp:TemplateField>
                                        <HeaderTemplate>
                                            No of Rooms to Lodge
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <center>
                                                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                                            </center>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <PagerStyle ForeColor="#053769" />
                                <HeaderStyle BackColor="#E1E2FA" ForeColor="#053769" />
                            </asp:GridView>
                            <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/Blue Coral DB.mdb"
                                SelectCommand="SELECT * FROM RoomList"></asp:AccessDataSource>
0
Dim i As Integer
        For i = 0 To GridView1.Rows.Count - 1
            Dim chk As CheckBox = CType(GridView1.Rows(i).Cells(0).FindControl("CheckBox1"), CheckBox)
            If chk.Checked Then
                '
            End If
        Next
0

I will suggest you to use RowDataBound even of griedview where you can cath each row of gridview and use FindControl method in this event.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.