本文介绍了嗨我在mvc4中使用webgrid通过使用json我绑定数据到gridview取决于下拉选择当我点击任何特定行我想要显示行数据到文本框。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1.这是我的j查询,这是不完整的,我试图通过使用jquery点击一行我在获取行ID时,我在如何将特定行数据绑定到文本框后使用alert方法点击特定行br $>




< script>

$(function(){

$ ('#grid tr')。live('hover',function(){



$(this).toggleClass('clickable');

})。live('click',function(){

//alert($(this).find('td:first').text());

$(this).find('td')。text()

var id =($(this).find('td:first')。text() );

alert(id);

$ .ajax({

url:'@ Url.Action(BindUser,Home )',

类型:'post',

数据:{id:id}





});





})



});



< / script>



2)通过使用url操作重定向到控制器获取id之后使用id iam重新定位数据但我无法获取数据到文本框。



public ActionResult BindUser(int id)

{



UserDb tbl = new UserDb();

SelectUserAccByPersonID_Result result1 = new SelectUserAccByPersonID_Result();

var UserSelect = db.SelectUserAccByPersonID(id).ToList();

ViewBag.txtFatherSurname = UserSelect.Select(j => j.txtFatherSurname)。单个();

ViewBag.txtUserName = UserSelect.Select(j => j.txtUserName).Single();

ViewBag.txtPassword = UserSelect.Select(j => j.txtPassword).Single();

return View(tbl);



// UserDb tbl = new UserDb();

// var UserSelect = db.SelectUserAccByPersonID(id).ToList();

//返回Json(UserSelect);



}

1.this is my j query which is incomplete which i am try to click a row by using jquery i am getting row id when i click on particular row by using alert method after how to bind particular row data to text boxes


<script>
$(function () {
$('#grid tr').live('hover', function () {

$(this).toggleClass('clickable');
}).live('click', function () {
//alert($(this).find('td:first').text());
$(this).find('td').text()
var id = ($(this).find('td:first').text());
alert(id);
$.ajax({
url: '@Url.Action("BindUser", "Home")',
type: 'post',
data: { id: id }


});


})

});

</script>

2)After Getting the id by using url action redirecting to controller Method by using the id iam retreving the data but i cant get the data to textboxes.

public ActionResult BindUser(int id)
{

UserDb tbl = new UserDb();
SelectUserAccByPersonID_Result result1 = new SelectUserAccByPersonID_Result();
var UserSelect = db.SelectUserAccByPersonID(id).ToList();
ViewBag.txtFatherSurname = UserSelect.Select(j => j.txtFatherSurname).Single();
ViewBag.txtUserName = UserSelect.Select(j => j.txtUserName).Single();
ViewBag.txtPassword = UserSelect.Select(j => j.txtPassword).Single();
return View(tbl);

//UserDb tbl = new UserDb();
//var UserSelect = db.SelectUserAccByPersonID(id).ToList();
//return Json(UserSelect);

}

推荐答案




这篇关于嗨我在mvc4中使用webgrid通过使用json我绑定数据到gridview取决于下拉选择当我点击任何特定行我想要显示行数据到文本框。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 18:34