Solved

inner gridview with ascx - database does not update

Posted on 2011-03-19
1
905 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 …
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

707 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