?
Solved

inner gridview with ascx - database does not update

Posted on 2011-03-19
1
Medium Priority
?
907 Views
Last Modified: 2012-08-14
I have an inner gridview with an ascx file.  When I update the row of the inner gridview the field in the ascx file is null on the database.  How can I get the stored procedure paramenter to recognize the ascx field? Below are the gridview and the ascx file.

  <asp:GridView ID="ParentGrid" runat="server" AutoGenerateColumns="False" DataSourceID="Names" ShowHeader="False">
         <Columns>
            <asp:TemplateField Visible="False">
               <ItemTemplate>
                    <asp:Label ID="Key" runat="server" Text='<%# Bind("Key") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                  <asp:TextBox ID="TB1" runat="server" Text='<%# Bind("Key") %>'></asp:TextBox>
                 </EditItemTemplate>
               </asp:TemplateField>
                                             
                    <asp:TemplateField>
                        <ItemTemplate>
                      <asp:Label ID="Lab10" runat="server" Text='<%# Bind("name") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                     <asp:Label ID="Lab10" runat="server" Text='<%# Bind("name") %>' ></asp:Label>
                             </EditItemTemplate>
                    </asp:TemplateField>
           
                    <asp:TemplateField>
                        <ItemTemplate>
       <asp:GridView ID="DetailGrid" runat="server" DataSourceID="getData" AutoGenerateColumns="False" DataKeyNames="Keys">
                <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"  />
                        </EditItemTemplate>
                        <ItemTemplate>
    <asp:Button ID="Button1" runat="server" CausesValidation="False" CommandName="Edit"  />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="eventTeamHotelKey" Visible="False">
                        <EditItemTemplate>
                   <asp:TextBox ID="TxtB1" runat="server"  Text='<%# Bind("Key") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                  <asp:Label ID="Label1" runat="server" Text='<%# Bind("Key") %>'></asp:Label>
                        </ItemTemplate>
                   </asp:TemplateField>
                  <asp:TemplateField HeaderText=" Number" >
                   <EditItemTemplate>
          <asp:Label ID="Label1" runat="server" Text='<%# Eval("number") %>'  ></asp:Label>
                           
                        </EditItemTemplate>
                        <ItemTemplate>
     sp:Label ID="Label2" runat="server" Text='<%# Bind("number") %>'></asp:Label>
                         </ItemTemplate>
                          </asp:TemplateField>
                    <asp:TemplateField HeaderText="Name">
                        <EditItemTemplate>
      <asp:Label ID="Label2" runat="server" Text='<%# Eval("Name") %>' ></asp:Label>
                        </EditItemTemplate>
                        <ItemTemplate>
        <asp:Label ID="Label3" runat="server" Text='<%# Bind("Name") %>' ></asp:Label>
                        </ItemTemplate>
             </asp:TemplateField>
                    <asp:TemplateField HeaderText=" First Name">
                        <EditItemTemplate>
         <asp:TextBox ID="FirstName" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
           <asp:Label ID="Label4" runat="server" Text='<%# Bind("FirstName") %>' ></asp:Label>
                        </ItemTemplate>
     </asp:TemplateField>
                    <asp:TemplateField HeaderText="Type" >
                          <ItemTemplate>
            <asp:DropDownList ID="Type" runat="server" DataSourceID="Type" AppendDataBoundItems="true"
                DataTextField="nam" DataValueField="Type"  Enabled="false" SelectedValue='<%# Bind("Type")%>'>
        <asp:ListItem Value="-1" Selected="True">Type Not Selected</asp:ListItem>
                 </asp:DropDownList>      
                               
                        </ItemTemplate>
                        <EditItemTemplate>
           <asp:DropDownList ID="Type" runat="server" DataSourceID="Type" AppendDataBoundItems="true"
                DataTextField="nam" DataValueField="Type" SelectedValue='<%# Bind("Type")%>'>
            <asp:ListItem Value="-1" Selected="True">Type</asp:ListItem>
            </asp:DropDownList>      
                                                         
                        </EditItemTemplate>
                     
</asp:TemplateField>
                    <asp:TemplateField HeaderText="Month" >
                        <EditItemTemplate>
                             
                            <CCMON:ccmonth id="Month1" runat="server" />  
                         
                        </EditItemTemplate>
                        <ItemTemplate>
                 
                              <CCMON:ccmonth id="Month1" runat="server"/>
                        </ItemTemplate>
   </asp:TemplateField>
                </Columns>
         
            </asp:GridView>

            <asp:SqlDataSource ID="getData" runat="server"
                ConnectionString="<%$ ConnectionStrings %>"
           
                 updateCommand="sp_update_detail"  UpdateCommandType="StoredProcedure">
                </SelectParameters>      
                     <UpdateParameters>
                    <asp:Parameter Name="Key" Type="Int32" />
                    <asp:Parameter Name="number" Type="Int32" />
                    <asp:Parameter Name="FirstName" Type="String" />
                    <asp:Parameter Name="Type" Type="String" />
                    <asp:Parameter Name="Month"  Type="Int32"   />
                </UpdateParameters>
            </asp:SqlDataSource>
                          </ItemTemplate>
                      </asp:TemplateField>
                </Columns>
     
            </asp:GridView>

Monthcalc.ascx

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="MonthCalc.ascx.vb" Inherits="MonthCalc" %>
<asp:DropDownList ID="Month" runat="server" SelectedValue='<%# Bind("Month")%>' >
</asp:DropDownList>
<asp:RequiredFieldValidator ControlToValidate="Month" ID="MonthRFV" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>  


Partial Class MonthCalc
    Inherits System.Web.UI.UserControl

    Protected Sub Month_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Month.Init
        Dim intMonth As Integer
        Dim intStart As Integer = DateTime.Now.Year
        Dim intEnd As Integer = DateTime.Now.Year + 10

        For intMonth = 1 To 12
            Month.Items.Add(intMonth.ToString())
        Next
        Month.Items.Add(New ListItem("Month", "-1"))

    End Sub
End Class
0
Comment
Question by:kw66722
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
kw66722 earned 0 total points
ID: 35176261
I created a hidden field for the ascx control. Saved the selected value to the hidden field and changed from a parmater to a controlParameter.  I was able to save the information doing that.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

762 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