Hi,
I have a gridview like below in my view
<table id="list" cellspacing="0" cellpadding="0">
<tr>
<th>
@Html.DisplayNameFor(model => model.UserName)
</th>
@*<th>
@Html.DisplayNameFor(model => model.Password)
</th>*@
<th>
@Html.DisplayNameFor(model => model.Address)
</th>
<th>
@Html.DisplayNameFor(model => model.MobileNumber)
</th>
<th>
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.UserName)
</td>
@* <td>
@Html.DisplayFor(modelItem => item.Password)
</td>*@
<td>
@Html.DisplayFor(modelItem => item.Address)
</td>
<td>
@Html.DisplayFor(modelItem => item.MobileNumber)
</td>
<td>
@*@Html.ActionLink("Edit", "../SaveData/SaveData", new { id = item.UserID }) |*@
@Html.ActionLink("Edit", "Details", new { id = item.UserID }, new { @class = "details-modal", @onclick = "javascript:foo();" })
@Html.ActionLink("Delete", "Delete", new { id = item.UserID })
</td>
</tr>
}
when click on the action link a popup is showing. the code used in linke below
@{
var user = (User)ViewData["userdetails"];
//if (ViewData["userdetails"] != null)
//{
// ViewBag.username = @user.UserName;
//}
//ViewBag.userdata="fdfdsfsdfsdfsd";
//ViewBag.userdata=@user.UserName;
@Html.ValidationSummary(true);
<input type="text" id="user" />
@Html.LabelFor(model => @user.UserName)
@Html.EditorFor(model => @user.UserName)
@Html.ValidationMessageFor(model => @user.UserName)
@Html.LabelFor(model => @user.Password)
@Html.Password("Password")
@Html.ValidationMessageFor(model => @user.Password)
@Html.LabelFor(model => @user.Address)
@Html.EditorFor(model => @user.Address)
@Html.ValidationMessageFor(model => @user.Address)
@Html.LabelFor(model => @user.MobileNumber)
@Html.EditorFor(model => @user.MobileNumber)
@Html.ValidationMessageFor(model => @user.MobileNumber)
<input type="submit" value="Create" />
}
<script type="text/jscript">
$('#my-dialog').dialog({
autoOpen: false,
width: 400,
resizable: false,
modal: true
});
$('.details-modal').click(function () {
//var username = '@ViewBag.username';
//document.getElementById('user').value = username;
var theURL = $(this).attr('href');
$('#my-dialog').load(theURL, function () {
$(this).dialog('open');
});
return false; // ensures the browser is not redirected to the link's URL
});
i want to populate each textbox with the corresponding data in the clicked row. how can i possible?