Solved

edit inner gridview

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hidden Field Value 10 57
Recommendation vb6 to vb.net or others 14 104
C#  Radio button search for Date not DateTime 4 30
Message not shown 5 26
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…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and 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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

948 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

23 Experts available now in Live!

Get 1:1 Help Now