Solved

edit inner gridview

Posted on 2011-03-12
4
346 Views
Last Modified: 2012-05-11
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.
0
Comment
Question by:kw66722
  • 3
4 Comments
 
LVL 6

Expert Comment

by:AkAlan
ID: 35117936
CAn you post the code for your grid?
0
 
LVL 1

Author Comment

by:kw66722
ID: 35123590
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
0
 
LVL 1

Accepted Solution

by:
kw66722 earned 0 total points
ID: 35176283
No sure how I got this to work I got it working
0
 
LVL 1

Author Closing Comment

by:kw66722
ID: 35213310
I got the code to work.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now