Terry

Terry

  • NA
  • 115
  • 0

Suggestion for Such a View

May 8 2015 7:27 AM

Hello, 


   I have a FormView to Insert records to the DB. It works fine. Here is the pattern of it :
        <asp:FormView runat="server" ID="InquiryInsertID"
            ItemType="VincitoreCRMApplication.Models.Inquiry" DefaultMode="Insert"
            InsertItemPosition="FirstItem" InsertMethod="InsertItem"
            OnItemCommand="ItemCommand" RenderOuterTable="false">
            <InsertItemTemplate>
                <fieldset class="form-horizontal">
<legend>Insert Inquiry Details</legend>
       <asp:ValidationSummary runat="server" CssClass="alert alert-danger" />

   <asp:DynamicControl Mode="Insert" DataField="InquiryDate" runat="server" />

<asp:DynamicControl Mode="Insert" 
DataField="ProjectName" 
DataTypeName="VincitoreCRMApplication.Models.Project" 
DataTextField="ProjectName" 
DataValueField="ProjectId" 
UIHint="ForeignKey" runat="server" />
<asp:DynamicControl Mode="Insert" 
DataField="ChannelId" 
DataTypeName="VincitoreCRMApplication.Models.Channel" 
DataTextField="ChannelFullName" 
DataValueField="ChannelId" 
UIHint="ForeignKey" runat="server" />

                            <asp:DynamicControl Mode="Insert" DataField="CampaignId" runat="server" />

                            <div class="form-group">
   <asp:DynamicControl Mode="Insert" DataField="NameSuffix" runat="server" />
   <asp:DynamicControl Mode="Insert" DataField="FirstName" runat="server" />
   <asp:DynamicControl Mode="Insert" DataField="LastName" runat="server" />
                            </div>

   <asp:DynamicControl Mode="Insert" DataField="Address" runat="server" />
   <asp:DynamicControl Mode="Insert" DataField="Area" runat="server" />
   <asp:DynamicControl Mode="Insert" DataField="Locality" runat="server" />
   <asp:DynamicControl Mode="Insert" DataField="City" runat="server" />
   <asp:DynamicControl Mode="Insert" DataField="State" runat="server" />
   <asp:DynamicControl Mode="Insert" DataField="Country" runat="server" />
<asp:DynamicControl Mode="Insert" DataField="Nationality" runat="server"  />
   <asp:DynamicControl Mode="Insert" DataField="ZipCode" runat="server" />



and lot more fields. All fields come in Vertical order - 1 after another. 

I want the same fields but in different format/view. Like a panel with a title on it for all Name & address details, another for other dates details, other firm details, etc. I also wish to have a link for each panel dept on top, thru which user can just navigate to that part of the page. 

Can you suggest me how can I achieve this ? I prefer to use DynamicControl as it becomes easy to handle the saving & retrieval part of the DB. Finally on the "Submit" button click, I can add the record using Model Binding :
        public void InsertItem()
        {
            Inquiry item = null;
            item = new Inquiry();
                //item.Id = 1;

                TryUpdateModel(item);

                if (ModelState.IsValid)
                {
                    //Inquiry newInq = item;

                    // Save changes
                    _db.Inquiries.Add(item);
                    //System.Diagnostics.Debug.WriteLine("###  ID OF Newly Created CHANNEL = " + newInq.Id);                // Save changes
                    _db.SaveChanges();
                    System.Diagnostics.Debug.WriteLine("###  EF ID OF Newly Created INQuiry = " + item.Id);

                    Response.Redirect("Default");
                }
        }

Can I place the same Dynamiccontrol's in different Panels or div and make the LnF different ? And on Submit button call the InsertItem code ? If I use DynamicControl, then I guess I will have to mention the Model Type of it. How and where can I add that ?

Can you please help me solve these queries and help me create different View using Model Binding.

Yet, all suggestions are welcome.


Kindly suggest to your best based on my needs. 

Thanks

Answers (3)