MVC3我要添加一条数据到数据库,在Controller层怎么获取到View层中文本框中的值,传到BLL层,不用Ajax

MVC3我要添加一条数据到数据库,在Controller层怎么获取到View层中文本框中的值,传到BLL层,不用Ajax,第1张

比如view中的表单如下:

<form >

<input name="Name" />

<input name="Age" />

</form>

Action可以这么写:

public ActionResult Save(string Name,int Age){

//

}

注意看input的名称要与action 参数名称对应。

实际上可以加个Model类:

public class User{

public string Name{get;set;}

public int Age{get;set;}|

}

action就这么写:

public ActionResult Save(User user){

//会自动绑定

}

getText() 的返回值类型是Editable

而常用的的转化为字符串的方法就是toStrint()方法

toString()方法是特有的一个方法,而没有toInt()这个方法,想转化为int型的,就要先强转成String的,然后再由String的强转成int的

如果有问题可以多查一下android 的 api 帮助文档,对你很有帮助的

Activity的 *** 作:

listViewsetOnItemClickListener(new OnItemClickListener() {

@Override

public void onItemClick(AdapterView<> parent, View view,

int position, long id) {

// TODO Auto-generated method stub

//通过 *** 作getItem这个方法来得到

parentgetAdapter()getItem(position);

}

});

Adapter的 *** 作

@Override

public Object getItem(int position) {

return 你要返回的数据;

}

private void TVdepartment_ItemDrag(object sender, ItemDragEventArgs e)//左键拖动

{

if (eButton == MouseButtonsLeft)

{

DoDragDrop(eItem, DragDropEffectsMove);

}

}

private void TVdepartment_DragEnter(object sender, DragEventArgs e)

{

if (eDataGetDataPresent("SystemWindowsFormsTreeNode"))

{

eEffect = DragDropEffectsMove;

}

else

{

eEffect = DragDropEffectsNone;

}

}

private void TVdepartment_DragDrop(object sender, DragEventArgs e)//拖动

{ //获得拖放中的节点

TreeNode moveNode = (TreeNode)eDataGetData("SystemWindowsFormsTreeNode");

//根据鼠标坐标确定要移动到的目标节点

Point pt;

TreeNode targeNode;

pt = ((TreeView)(sender))PointToClient(new Point(eX, eY));

targeNode = thisTVdepartmentGetNodeAt(pt);

//如果目标节点无子节点则添加为同级节点,反之添加到下级节点的未端

TreeNode NewMoveNode = (TreeNode)moveNodeClone();

if (targeNodeNodesCount == 0)

{

targeNodeParentNodesInsert(targeNodeIndex, NewMoveNode);

}

else

{

targeNodeNodesInsert(targeNodeNodesCount, NewMoveNode);

}

//更新当前拖动的节点选择

TVdepartmentSelectedNode = NewMoveNode;

//展开目标节点,便于显示拖放效果

targeNodeExpand();

//移除拖放的节点

moveNodeRemove();

}

以上就是关于MVC3我要添加一条数据到数据库,在Controller层怎么获取到View层中文本框中的值,传到BLL层,不用Ajax全部的内容,包括:MVC3我要添加一条数据到数据库,在Controller层怎么获取到View层中文本框中的值,传到BLL层,不用Ajax、android关于获取文本框的值的问题、android如何点击某个按钮后获取gridview指定item里的TextView的文本等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9751533.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-01
下一篇2023-05-01

发表评论

登录后才能评论

评论列表(0条)

    保存