Hi Frnds
I am sending to u my code ...but i am stuck in if i click on add button new row is not be add on the web grid in mvc4
please chek the code and give the solution
Model////
public class UserModel
{
public int ID { get; set; }
public string Name { get; set; }
public string LastName { get; set; }
//public static List
//{
// List
// {
// new UserModel();
// /*{ ID = 1, Name = "Anubhav", SurName = "Chaudhary" }; */
// };
// users.Add(new UserModel());
// //{ ID = 1, Name = "Anubhav", SurName = "Chaudhary" });
// return (users);
//}
public static List
{
List
{
new UserModel (){ ID=4, Name="Jyoti", LastName="Mishra" },
new UserModel (){ ID=5, Name="Shayli", LastName="Shamra" },
};
return users;
}
}
Views////
@{
ViewBag.Title = "Index";
}
WEB GRID
@{
var grid = new WebGrid(Model);
}
@grid.GetHtml(
columns:
grid.Columns(
grid.Column("ID", format: @
@item.ID
grid.Column("Name", "Name", format: @
grid.Column("LastName", "LastName", format: @
)
))
@*Add button for adding the textbox*@
Controller/////
public ActionResult Index()
{
List
return View(users);
}
Midhun TpRank #388 · 6.5K reputationPosted Sep 6, 2016, 8:21 PM EDT
Vinay SinghRank #604 · 4K reputationPosted Aug 25, 2016, 11:11 PM EDT
Anjali KhanRank #1,649 · 931 reputationPosted Aug 25, 2016, 11:32 PM EDT
Anjali KhanRank #1,649 · 931 reputationPosted Aug 26, 2016, 1:26 AM EDT
Anjali KhanRank #1,649 · 931 reputationPosted Sep 5, 2016, 8:46 PM EDT
Midhun TpRank #388 · 6.5K reputationPosted Sep 5, 2016, 10:43 PM EDT
Midhun TpRank #388 · 6.5K reputationPosted Sep 5, 2016, 10:52 PM EDT
Midhun TpRank #388 · 6.5K reputationPosted Sep 5, 2016, 11:18 PM EDT
Vinay SinghRank #604 · 4K reputationPosted Sep 5, 2016, 11:29 PM EDT
{
List
return View(users);
}
{
List
return View(users);
}
Anjali KhanRank #1,649 · 931 reputationPosted Sep 5, 2016, 11:50 PM EDT
Midhun TpRank #388 · 6.5K reputationPosted Sep 5, 2016, 11:50 PM EDT
Anjali KhanRank #1,649 · 931 reputationPosted Sep 6, 2016, 12:29 AM EDT
Anjali KhanRank #1,649 · 931 reputationPosted Sep 6, 2016, 8:15 PM EDT
why new row is adding after the button..or it is adding outside the grid ..means i want only row should be add on grid..
Anjali KhanRank #1,649 · 931 reputationPosted Sep 6, 2016, 9:01 PM EDT
Anjali KhanRank #1,649 · 931 reputationPosted Sep 6, 2016, 9:08 PM EDT
hey
if i added a new row and fillup and add again new row
previous data is showing on new row?
Midhun TpRank #388 · 6.5K reputationPosted Sep 6, 2016, 10:04 PM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts