---
title: "Fill a form with ASP MVC Querystring"  
description: "Fill a form with ASP MVC Querystring"  
author: "Anonymous User"  
published: 2014-12-26  
updated: 2014-12-26  
canonical: https://www.mindstick.com/forum/12816/fill-a-form-with-asp-mvc-querystring  
category: ".net"  
tags: ["asp.net", "mvc"]  
reading_time: 2 minutes  

---

# Fill a form with ASP MVC Querystring

I want to fill a form with Id and i have made the url in this way\
local-host:1613/[Patient](https://yourviews.mindstick.com/view/81705/what-exactly-happens-when-a-patient-gets-into-coma)/[Index](https://www.mindstick.com/blog/198/index-in-sql-server)/1\
Where as 1 is the Id. And i want to fill my form with the data of patient with Id 1. But this below [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) is not being called in [Controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc)\

```
 public ActionResult Index(int id)        {            Patient p = new CEntities().Patients.Find(id);            return View(p);        }//instead, i am getting into public ActionResult Index()        {            return View();        }
```

I am new bie in ASP MVC, i have no idea in [filling](https://yourviews.mindstick.com/audio/1303/the-power-of-silence-what-happens-when-you-stop-filling-every-moment) a form with any other way, i found a way but it [shows](https://yourviews.mindstick.com/view/81380/new-york-violent-shooting-shows-people-are-not-safe-in-night-life) my whole object in [query string](https://www.mindstick.com/articles/512/query-string-in-asp-dot-net) which is insecure. And this above [solution is not working](https://www.mindstick.com/forum/160480/find-all-in-entire-solution-is-not-working-properly-in-visual-studio-2022).

## Replies

### Reply by Anonymous User

As far as I know you cannot truly overload action methods in ASP.NET-MVC so there can be only one Index action method(without any additional annotations). Of course you can define few methods with the same name but then you might want to add [HttpPost](or other HTTP method) annotation above the action method to use it for instance after submitting a form.\
**Making parameter optional might be helpful:**\

```
public ActionResult Index(int? id){        if(id.HasValue()){            Patient p = new CEntities().Patients.Find(id);            return View(p);         }   return View();        }
```

Please take a look: Can you overload controller methods in ASP.Net MVC?Another advice: try to use scaffolding and see how template does it for you:\
1.Right click on a controller folder\
2.Add->New Controller\
3.Controller with Entity Framework read/write actions(as far as I remember 3rd from the top)\
4.Select model class.\
5.Select db context(class which maintains connection with database).\
6.Ok.It will generate controller with views, have fun.


---

Original Source: https://www.mindstick.com/forum/12816/fill-a-form-with-asp-mvc-querystring

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
