English 中文(简体)
c#和ASP.NET Gridview-数据库中的文本框数据更新
原标题:c# & ASP.NET Gridview- Textbox data update in DB
  • 时间:2011-05-09 13:36:42
  •  标签:
  • c#
  • asp.net

我有一个网格视图,大约有六列,其中一列是文本框。

用户可以在文本框中输入一个值,当他单击提交按钮(该按钮不在网格视图中)时,必须将单个值更新到数据库中。网格视图中的所有其他列都将从数据库中检索。但这一列必须更新到DB中。用户可以为此可编辑列输入一行或所有行(记录)的数据。

每当gridview中的文本框发生文本更改事件时,我都需要更新该特定记录的数据。

当编辑许多行时,请建议如何获得该特定列的值。

提前谢谢。

问题回答

我只需要在每个文本框中添加一个onChange或onKeyDown方法,然后用JavaScript编写一个方法来只更新该字段。

<input type="text" id="myTextBox" onchange="$:someJavaScriptMethod()" />

如果您想在服务器端处理它,您可以订阅TextBox的TextChanged事件,但不需要返回TextBox帖子。当提交按钮执行回发时,将调用TextChanged事件的事件处理程序。在事件处理程序中,您可以将文本持久化到DB中。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签