asp.net中怎么对数据进行单条的编辑,用textbox而不用datagrid asp.net要对数据库进行操作,编辑,添加删除,除了用datagrid之外,还可以用其他的控件来操作吗?比如textbox,因为我想一条一条的来编辑这些数据,而不是用datagrid那种表的方式来编辑,在其他的RAD工具中,好象有DBtextbox这样的控件的,我看textbox中只能绑定他的text属性。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 把datagrid里面的数据绑定到textbox然后修改 你是根本不打算用DATAGRID的话,直接绑定数据给TextBox就得了。 将值付给textbox 不就可以了。 protected static int nRowsPos;protected DataSet ds;private string TxtBindData(string fieldName) { DataSet ds=rule.Employee.selectAll(); string buf=ds.Tables[0].Rows[nRowsPos] [fieldName].ToString(); return buf; } private void RefLinkBtn_Click(object sender, System.EventArgs e) //上一条纪录 { if(nRowsPos!=0) { nRowsPos-=1; this.IdTxt.Text=TxtBindData("EmployeeID"); this.FirstNameTxt.Text=TxtBindData("FirstName"); this.LastNameTxt.Text=TxtBindData("LastName"); } else { MyJS.JScript.Alert("已是第一条纪录!"); } }private void NextLinkBtn_Click(object sender, System.EventArgs e) //下一条纪录 { ds=rule.Employee.selectAll(); if( nRowsPos <ds.Tables[0].Rows.Count-1) { nRowsPos+=1; this.IdTxt.Text=TxtBindData("EmployeeID"); this.FirstNameTxt.Text=TxtBindData("FirstName"); this.LastNameTxt.Text=TxtBindData("LastName"); } else { MyJS.JScript.Alert("已是最后一条纪录!"); } }绑定textbox。对数据进行操作。 以前爱用DataGrid,但感觉过于烦琐,现在只要有列表需求的,全部用DataList,模版列... 我现在用的是formview就可以实现你说的。 可以啊,你可以用repeater控件,在itemtemplate中,加一个textbox,绑定repeater时,给textbox赋值,更新时,取这个textbox的值.itemtemplate中,设一个label,设visible=false,并绑定到一个主键,就可以了 请教个问题,路径问题。 Server Error in '/' Application(在线求指导) 如何将网上的图片保存到服务器目录中? button无法触发click事件 判断某节点是否是根节点? ASP.NET 怎样把c:\a.jpg 上传到一个目录下? 偶请教这是怎么一回事! asp.net的打印问题 问一个二级关联的问题! GridView如何过滤HTML代码 我用htm做了一個登陸葉面 在提交到login.aspx葉面出現以下錯誤 web程序无法调试了
直接绑定数据给TextBox就得了。
protected DataSet ds;
private string TxtBindData(string fieldName)
{
DataSet ds=rule.Employee.selectAll();
string buf=ds.Tables[0].Rows[nRowsPos]
[fieldName].ToString();
return buf;
}
private void RefLinkBtn_Click(object sender, System.EventArgs e) //上一条纪录
{
if(nRowsPos!=0)
{
nRowsPos-=1;
this.IdTxt.Text=TxtBindData("EmployeeID");
this.FirstNameTxt.Text=TxtBindData("FirstName");
this.LastNameTxt.Text=TxtBindData("LastName");
}
else
{
MyJS.JScript.Alert("已是第一条纪录!");
}
}private void NextLinkBtn_Click(object sender, System.EventArgs e) //下一条纪录
{
ds=rule.Employee.selectAll();
if( nRowsPos <ds.Tables[0].Rows.Count-1)
{
nRowsPos+=1;
this.IdTxt.Text=TxtBindData("EmployeeID");
this.FirstNameTxt.Text=TxtBindData("FirstName");
this.LastNameTxt.Text=TxtBindData("LastName");
}
else
{
MyJS.JScript.Alert("已是最后一条纪录!");
}
}
绑定textbox。对数据进行操作。