33 messaggi dal 03 dicembre 2004
Ciao a tutti,
ho dei seri problemi con una ListBox annidata in un formView in modalità EDIT..e sono alla prima esperienza con asp.net!

In pratica devo "gestire" una tabella in relazione 1aN con un'altra tabella e ho uno schema così:

tabella_padre
--id_padre
--campo1
--campo2

tabella_padre_figli
--id_padre
--id_figlio

tabella_figli
--id_figlio
--nome_figlio

Gestisco le operazioni di insert e update con due SP, in particolare quella di Update prende come ultimo parametro un serie di ID separati da spazi che poi vengono "splittati" nella tabella di relazione (tabella_padre_figli)

ALTER PROCEDURE [dbo].[p_updateClinical]
  -- Add the parameters for the stored procedure here
  @id_clinical_profile tinyint,
  @id_status tinyint,
  @id_therapeutic_area int,
  @id_recruitment_status int,
  @study_code varchar(max),
  @condition varchar(max),
  @generic_name varchar(max),
  @commercial_name varchar(max),
  @short_title varchar(max),
  @filename varchar(max),
  @filename_title varchar(max),
  @ids varchar(50)
AS
BEGIN

  DECLARE @current_id tinyint;

  UPDATE [clinical_profiles] SET [id_therapeutic_area] = @id_therapeutic_area, [id_recruitment_status] = @id_recruitment_status, [id_status] = @id_status, [study_code] = @study_code, [condition] = @condition, [generic_name] = @generic_name, [commercial_name] = @commercial_name, [short_title] = @short_title, [filename] = @filename, [filename_title] = @filename_title WHERE [id_clinical_profile] = @id_clinical_profile;

  DELETE FROM locations_clinical_profile WHERE id_clinical_profiles = @id_clinical_profile;

  INSERT INTO [locations_clinical_profile] ([id_geographic_location], [id_clinical_profiles])
    SELECT number, @id_clinical_profile FROM iter_intlist_to_table(@ids) i
END



Il problema è sulla formview che ho.. quando inserisco tutto ok..quando invece eseguo una modifica mi dice Procedure or function p_updateClinical has too many arguments specified.

Il formview è questo:

            <EditItemTemplate>
                <input type="hidden" name="id_clinical_profile" value="<%#Request.QueryString["id"]%>" />
                Approved: &nbsp;
                <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="SqlDataSource4"
                    DataTextField="status" DataValueField="id_status" SelectedValue='<%# Bind("id_status") %>'>
                </asp:DropDownList><br />
                <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                    SelectCommand="SELECT [id_status], [status] FROM [status]">
                </asp:SqlDataSource>
                <br /><br />

                Study code:
                <asp:TextBox ID="study_codeTextBox" runat="server" Text='<%# Bind("study_code") %>' Width="200px"></asp:TextBox><br />
                Therapeutic area: &nbsp;
                <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2"
                    DataTextField="therapeutic_area" DataValueField="id_therapeutic_area" SelectedValue='<%# Bind("id_therapeutic_area") %>'>
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [id_therapeutic_area], [therapeutic_area] FROM [therapeutic_area] WHERE ([id_lang] = @id_lang)">
                    <SelectParameters>
                        <asp:SessionParameter DefaultValue="1" Name="id_lang" SessionField="id_lang" Type="Byte" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <br />
                Geographic Locations:
                &nbsp;
                <asp:ListBox ID="ListBox1" runat="server" DataSourceID="SqlDataSource6" DataTextField="geographic_location"
                    DataValueField="id_geographic_location" SelectionMode="Multiple"></asp:ListBox><asp:SqlDataSource ID="SqlDataSource6" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                    SelectCommand="SELECT [id_geographic_location], [id_lang], [geographic_location] FROM [geographic_location] WHERE ([id_lang] = @id_lang)">
                    <SelectParameters>
                        <asp:SessionParameter Name="id_lang" SessionField="id_lang" Type="Byte" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <br />
                Condition:
                <asp:TextBox ID="conditionTextBox" runat="server" Text='<%# Bind("condition") %>'
                    Width="200px"></asp:TextBox><br />
                Generic name:
                <asp:TextBox ID="generic_nameTextBox" runat="server" Text='<%# Bind("generic_name") %>'
                    Width="200px"></asp:TextBox><br />
                Commercial name:
                <asp:TextBox ID="commercial_nameTextBox" runat="server" Text='<%# Bind("commercial_name") %>'
                    Width="200px"></asp:TextBox><br />
                Recruitment status:&nbsp;
                <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource3"
                    DataTextField="recruitment_status" DataValueField="id_recruitment_status" SelectedValue='<%# Bind("id_recruitment_status") %>'>
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                    SelectCommand="SELECT [id_recruitment_status], [recruitment_status] FROM [recruitment_status] WHERE ([id_lang] = @id_lang)">
                    <SelectParameters>
                        <asp:SessionParameter DefaultValue="1" Name="id_lang" SessionField="id_lang" Type="Byte" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <br />
                Short title:
                <asp:TextBox ID="short_titleTextBox" runat="server" Text='<%# Bind("short_title") %>'
                    Width="150px"></asp:TextBox><br />
                PDF File: <input type="file" id="File1" runat="server" name="attFile"><br />
                <a id="pdfFile" runat="server"></a><br />
                PDF title: <asp:TextBox ID="filename_titleTextBox" runat="server" Text='<%# Bind("filename_title") %>'></asp:TextBox><br />
                <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                    Text="Update"></asp:LinkButton>&nbsp;
                </div>
            </EditItemTemplate>


*********


        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            OldValuesParameterFormatString="original_{0}"
            SelectCommand="SELECT clinical_profiles.id_clinical_profile, clinical_profiles.id_therapeutic_area, clinical_profiles.id_recruitment_status, clinical_profiles.id_status, clinical_profiles.study_code, clinical_profiles.condition, clinical_profiles.generic_name, clinical_profiles.commercial_name, clinical_profiles.short_title, clinical_profiles.filename, clinical_profiles.filename_title, recruitment_status.recruitment_status, therapeutic_area.therapeutic_area, status.status FROM clinical_profiles INNER JOIN recruitment_status ON clinical_profiles.id_recruitment_status = recruitment_status.id_recruitment_status INNER JOIN therapeutic_area ON clinical_profiles.id_therapeutic_area = therapeutic_area.id_therapeutic_area INNER JOIN status ON clinical_profiles.id_status = status.id_status WHERE (clinical_profiles.id_clinical_profile = @id_clinical_profile) AND (clinical_profiles.id_lang = @id_lang)"
            InsertCommand="p_insertClinical"
            UpdateCommand="p_updateClinical"
            DeleteCommand="DELETE FROM [clinical_profiles] WHERE [id_clinical_profile] = @original_id_clinical_profile" InsertCommandType="StoredProcedure" UpdateCommandType="StoredProcedure">
            <DeleteParameters>
                <asp:Parameter Name="original_id_clinical_profile" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:QueryStringParameter Name="id_clinical_profile" QueryStringField="id" />
                <asp:Parameter Name="id_status" Type="Byte" />
                <asp:Parameter Name="id_therapeutic_area" Type="Int32" />
                <asp:Parameter Name="id_recruitment_status" Type="Int32" />
                <asp:Parameter Name="study_code" Type="String" />
                <asp:Parameter Name="condition" Type="String" />
                <asp:Parameter Name="generic_name" Type="String" />
                <asp:Parameter Name="commercial_name" Type="String" />
                <asp:Parameter Name="short_title" Type="String" />
                <asp:Parameter Name="filename" Type="String" />
                <asp:Parameter Name="filename_title" Type="String" />
                <asp:Parameter Name="ids" Type="String" />
            </UpdateParameters>
            <InsertParameters>
                <asp:SessionParameter DefaultValue="1" Name="id_lang" SessionField="id_lang" Type="Byte" />
                <asp:Parameter Name="id_therapeutic_area" Type="Int32" />
                <asp:Parameter Name="id_recruitment_status" Type="Int32" />
                <asp:Parameter Name="study_code" Type="String" />
                <asp:Parameter Name="condition" Type="String" />
                <asp:Parameter Name="generic_name" Type="String" />
                <asp:Parameter Name="commercial_name" Type="String" />
                <asp:Parameter Name="short_title" Type="String" />
                <asp:Parameter Name="filename" Type="String" />
                <asp:Parameter Name="filename_title" Type="String" />
                <asp:Parameter Name="ids" Type="String" />
            </InsertParameters>
            <SelectParameters>
                <asp:QueryStringParameter Name="id_clinical_profile" QueryStringField="id" />
                <asp:SessionParameter DefaultValue="1" Name="id_lang" SessionField="id_lang" Type="Byte" />
            </SelectParameters>
        </asp:SqlDataSource>


mentre formview1_onUpdating faccio

    protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
    {
            ListBox geographic_locations = (ListBox)FormView1.FindControl("ListBox1");
            
            foreach (ListItem elemento in geographic_locations.Items)
            {
                ids += elemento.Value + " ";
            }
            ids = ids.Substring(0, ids.Length - 1);

            e.NewValues.Add("ids", ids);
            e.NewValues.Add("id_clinical_profile", Request.QueryString["id"]);
            e.NewValues.Add("filename", "ciao.pdf");

            //throw new Exception(e.NewValues.Count.ToString());


Due domande..

1) Come posso risolvere?
2) Se volessi verificare da me quali sono i campi mancanti passati alla SP come faccio a vedere tutti i valori della collection e.NewValues??

Help plz!!
33 messaggi dal 03 dicembre 2004
Qualcuno mi sà aiutare? Sono abbastanza disperato..

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.