0

我是一只新蜜蜂,我需要关于以下网格视图问题的帮助。我有一个gridview,它的所有单元格都是文本框,外面有一个按钮,单击它必须将数据保存到数据库并更新gridview(对文本框的更改必须保存在数据库中,并且应该刷新网格更改数据)。

4

2 回答 2

0

An easy way to do above is to make a function i.e. loadGrid() that will populate the grid, and you can call it anywhere like in button_click event or it may be the Text_Validated event.

And try to explain your question and decorate it with your code.

Welcome to Stackoverflow !

于 2013-04-12T09:47:42.473 回答
0

Computers don't assume anything, you have to tell it exactly what you need it to do.

You'll need to have a function somewhere in your program that takes arguments and then passes those arguments as parameters to a database. When you click your button, read the values from your gridview cell text boxes, and pass those values as arguments to your function.

Code might look something like:

public void UpdateUser(int userId, string userName, string userDescription){
   // code to update database here
}

public void button1_OnClick(object obj, EventArguments e)
{
     UpdateUser(txtBoxUserID.Content, txtBoxNewUsername.Content, txtBoxUserDescription.Content);
     UpdateDatagrid();
}

That code isn't going to work, it's an example off the top of my head. Although the principle behind it is how you need to approach your problem. Hope that helps.

于 2013-04-12T09:47:47.883 回答