[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

inner gridview with ascx - database does not update

Posted on 2011-03-19
1
Medium Priority
?
908 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

656 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