i have 2 tabs. i am using asp.net mvc. with one tab i am able to insert data.but when i insert data from another tab table of first tab in backebd inserting null row
this is my view
@model MathuraApp.Models.CurrencyCreationModel
@{
ViewBag.Title = "currency";
Layout = "~/Views/Shared/_AccountLayout.cshtml";
}
<h2>currency</h2>
@**@
@Html.AntiForgeryToken()
BEGIN INLINE TABS PORTLET
<div class="widget">
<div class="widget-title">
<h4><i class="icon-user"></i></h4>
</div>
<div class="widget-body">
<div class="row-fluid">
<div class="span8">
</div>
</div>
</div>
</div>
<div class="tabbable custom-tab">
<h4>CurrencyCreationModel</h4>
<hr />
<ul class="nav nav-tabs">
<li class="active"><a href="#tab_1_1" data-toggle="tab">Currency Creation</a></li>
<li><a href="#tab_1_2" data-toggle="tab">Currency Converter</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane " id="tab_1_2">
@using (Html.BeginForm("Currency", "CurrencyCreation",FormMethod.Post,new { }))
{
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.SecondaryCurrency, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.SecondaryCurrency, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SecondaryCurrency, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.ConvRate, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.ConvRate, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ConvRate, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.PrimaryCurrency, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.PrimaryCurrency, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.PrimaryCurrency, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="submit" class="btn btn-default" />
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10" style="color:green">
@ViewBag.Message
</div>
</div>
}
</div>
<div class="tab-pane active " id="tab_1_1">
@using (Html.BeginForm("currency", "CurrencyCreation", FormMethod.Post, new { }))
{
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Currency_Name, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Currency_Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Currency_Name, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CurrencySymbol, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.CurrencySymbol, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.CurrencySymbol, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Abbreviation, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Abbreviation, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Abbreviation, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Sub_Currency, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Sub_Currency, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Sub_Currency, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Decimal_Place, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Decimal_Place, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Decimal_Place, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Comments, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Comments, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Comments, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="submit" class="btn btn-default" />
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10" style="color:green">
@ViewBag.Message
</div>
</div>
}
</div>
this is my controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MathuraApp.Repository;
using MathuraApp.Models;
namespace MathuraApp.Controllers
{
public class CurrencyCreationController : Controller
{
public ActionResult currency()
{
return PartialView();
}
[HttpPost]
public ActionResult currency(CurrencyCreationModel ccm)
{
try
{
if (ModelState.IsValid)
{
CurrencyCreationRepository ccr = new CurrencyCreationRepository();
if (ccr.Currency(ccm) )
{
ViewBag.Message = "Currency details added successfully";
}
CurrencyConverterRepository ccr1 = new CurrencyConverterRepository();
if (ccr1.Currency(ccm))
{
ViewBag.Message = "Currencyconverter details added successfully";
}
}
return PartialView(ccm);
}
catch
{
return PartialView(ccm);
}
}
}
}