Solved

edit inner gridview

Posted on 2011-03-12
4
348 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Turn on intranet settings 1 57
ASP.net Fit 3 divs on screen side by side 3 26
jquery progress bar 3 42
jQuery - following an example but can I save data server side? 20 50
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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…

777 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