Link to home
Start Free TrialLog in
Avatar of kw66722
kw66722

asked on

edit inner gridview

I have an inner grid I want to edit.  When I click the inner grid edit button nothing shows from the inner grid.  How can I edit the inner grid? I am using VB net to code.
Avatar of AkAlan
AkAlan

CAn you post the code for your grid?
Avatar of kw66722

ASKER

To explain is better:
 I have two tables saved in a SQL database one table (parent) has the title for the field the other has the detailed (child) data based on the id of the parent table.  I want to edit the rows from the child table and not the parent table.  I have attached the possible layouts.  I tried to do this with 2 gridviews and could not get the edit to work for the inner grid.

  <asp:GridView ID="titleGrid" runat="server" AutoGenerateColumns="False"
                DataSourceID="titleSP" DataKeyNames="Key"
                ShowHeader="False">
                <Columns>
                    <asp:TemplateField Visible="False">
                        <ItemTemplate>
                            <asp:Label ID="keyLabel" runat="server" Text='<%# Bind("Key") %>'></asp:Label>
                        </ItemTemplate>
                       </asp:TemplateField>
                                           
                       
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:Label ID="Label10" runat="server" Text='<%# Bind("title") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                               
                    <asp:TemplateField>
                        <ItemTemplate>
                         <asp:GridView ID="DetailGrid" runat="server" DataSourceID="detailSP"
                AutoGenerateColumns="False" DataKeyNames="Key">
                <Columns>
                    <asp:TemplateField ShowHeader="False">
                        <EditItemTemplate>
                            <asp:Button ID="Button1" runat="server" CausesValidation="True"
                                CommandName="Update" Text="Save" />
                            &nbsp;<asp:Button ID="Button2" runat="server" CausesValidation="False"
                                CommandName="Cancel" Text="Cancel" />
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Button ID="Button1" runat="server" CausesValidation="False"
                                CommandName="Edit" Text="Edit" />
                        </ItemTemplate>
                     <ItemStyle Font-Names="verdana,arial,helvetica" Font-Size="9px" />
                    </asp:TemplateField>
                    <asp:TemplateField Visible="False">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server"
                                Text='<%# Bind("Key") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("Key") %>'></asp:Label>
                        </ItemTemplate>
                       <ItemStyle Font-Names="verdana,arial,helvetica" Font-Size="9px" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="data" SortExpression="data">
                        <EditItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("data1") %>'></asp:Label>
                           
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("data1") %>'></asp:Label>
                         </ItemTemplate>
                            <ItemStyle Font-Names="verdana,arial,helvetica" Font-Size="9px" />
                             <HeaderStyle Font-Names="verdana,arial,helvetica;" Font-Size="9px" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="data2" >
                        <EditItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text='<%# Eval("data2") %>'></asp:Label>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label3" runat="server" Text='<%# Bind("data2") %>'></asp:Label>
                        </ItemTemplate>
                           <ItemStyle Font-Names="verdana,arial,helvetica" Font-Size="9px" />
                    </asp:TemplateField>
                 
                </Columns>
               
                   <AlternatingRowStyle BackColor="#99CCFF" />
                  <SelectedRowStyle BackColor="#0033CC" />
               
            </asp:GridView>
            <asp:SqlDataSource ID="detailSP" runat="server"
                ConnectionString="<%$ ConnectionStrings:sql %>"
                SelectCommand="sp_detail" SelectCommandType="StoredProcedure"
                updateCommand="sp_detail"  UpdateCommandType="StoredProcedure">
                <SelectParameters>
                    <asp:ControlParameter ControlID="titleGrid" Name="key"
                        PropertyName="SelectedValue" Type="Int32" />
                 </SelectParameters>          

                <UpdateParameters>
                    <asp:Parameter Name="Key" Type="Int32" />
                    <asp:Parameter Name="data1" Type="Int32" />
                    <asp:Parameter Name="data2" Type="String" />
                </UpdateParameters>
            </asp:SqlDataSource>
                          </ItemTemplate>
                      </asp:TemplateField>
                </Columns>
     
            </asp:GridView>
           
            <asp:SqlDataSource ID="titleSP" runat="server"
                ConnectionString="<%$ ConnectionStrings:sql %>"
                SelectCommand="sp_title" SelectCommandType="StoredProcedure">
                <SelectParameters>
                    <asp:ControlParameter ControlID="middleimg$teamHotelID" Name="team_hotel_id"
                        PropertyName="Value" Type="Int32" />
                    <asp:ControlParameter ControlID="middleimg$eventID" Name="event_key_id"
                        PropertyName="Value" Type="Int32"  />
                </SelectParameters>
            </asp:SqlDataSource>      
               
           

sampleLayouts.doc
ASKER CERTIFIED SOLUTION
Avatar of kw66722
kw66722

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kw66722

ASKER

I got the code to work.