Getting data from two tables

user3405577

I have 2 tables tbl_computer and tbl_computerperipheral I need a editor view which consists of data from both tables.

How Can I get 2 tables in a single view so that I can insert data into 2 tables at once.

Thanx

user3405577

[HttpPost]

    public ActionResult Edit(CompPeripheral cp, int c_id,int em_id,int asset_id)
    {
        if (ModelState.IsValid)
        {
            cp.Compconfig.c_id = c_id;
            cp.Compconfig.em_id = em_id;
            cp.Compconfig.asset_id = asset_id;
            db.tbl_compconfig.Add(cp.Compconfig);
            db.SaveChanges();
            var id = db.tbl_compconfig.Max(a => a.comp_id);
            cp.Comperipheral.comp_id = id;
            //saving Comp Peripheral in database
            db.tbl_comperipheral.Add(cp.Comperipheral);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        ViewBag.asset_id = new SelectList(db.tbl_assetm, "asset_id", "asset_name", cp.Compconfig.asset_id);
        ViewBag.em_id = new SelectList(db.tbl_employee, "em_id", "em_fullname", cp.Compconfig.em_id);
        ViewBag.c_id = new SelectList(db.tbl_client, "c_id", "c_name", cp.Compconfig.c_id);
        return View(cp);
    }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Getting select data from two tables where session id

From Dev

Getting data from identical named fields in two different tables

From Dev

Getting select data from two tables where session id

From Dev

Hibernate: getting data from two linked tables using Ctriteria API

From Dev

Getting Data from more than two tables in Codeigniter

From Dev

getting wrong count when getting data from tables based on two dates

From Dev

Join data from two tables

From Dev

Compare data from two tables

From Dev

deleting data from two tables

From Dev

MYSQL - Getting Values From Two Tables on Match

From Dev

Mysql query for getting values from two tables

From Dev

Getting Distinct Count from two tables

From Dev

Getting data from multiple tables using a join

From Dev

Getting data from 2 tables in magento

From Dev

SQL query for getting data from 3 tables

From Dev

MYSQL getting data from three tables

From Dev

getting data from 2 tables and writing a query

From Dev

getting data from three tables with conditions

From Dev

Search data from two different tables that two tables in different databases

From Dev

Combine data from two different junction tables

From Dev

Counting and selecting data from two tables

From Dev

Fetch data From Two tables using Linq

From Dev

Selecting data from two tables with sql query

From Dev

Find uncommon data from two tables in mysql

From Dev

Delete data from two tables with INNER JOIN

From Dev

SQL query: combining data from two tables

From Dev

Group data by date from two SQL tables

From Dev

show data from two tables (menu & submenu )

From Dev

How to correlate data from two separate tables

Related Related

HotTag

Archive