如何在运行时从文本框向datagrid中添加数据? [英] How to add data into datagrid from textbox at run time?

查看:71
本文介绍了如何在运行时从文本框向datagrid中添加数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家下午好.

我想知道在运行时以表格形式将数据从现有文本框输入到DataGrid(或GridView)的代码.我没有从数据库获取任何数据来填充DataGrid.

如果我需要在表单中更清楚地说明,我已经放置了10个文本框,当我在DropdownList中选择一个项目时,可以用数据库中的值填充这些文本框.现在,当我单击一个按钮以表格形式查看这些详细信息时,所有这些文本框内容都将添加到dataGrid中.我也想知道添加其他文本的代码,这些文本不能来自文本框,但可以在运行时从我的代码中获取.

请任何人帮我.

在此先感谢

ganesh

Good Afternoon to all.

I would like to know the code to enter data from existing textboxes to a DataGrid(or GridView) in a form at run time. I don''t get any data from Database to fill the DataGrid.

If I need to explain more clearly in my form I have placed 10 textboxes which can be filled by the values from database when I select an Item in DropdownList. now when I click a button to view these details as a table all these textboxes content to be added to the dataGrid. and also I would like to know the code for Adding Some other text which cannot be from textboxes, but can be obtained from my code at run time.

Please any one help me.

Thanks in advance

ganesh

推荐答案

您需要一些数据源来绑定您的gridview.通常,数据源来自数据库或某些文件系统.

可能您有一些不同的要求.您可以从文本框中获取所有数据,然后获取数据源(如datatable等)并将其绑定到gridview.

如果要动态格式化或更改网格中的某些内容,请实施gridview的rowdatabound event
You need some datasource to bind your gridview. Normally datasource comes from database or some file system.

Might be you hve some different requirement. You can get all the data from your textboxes and have then is datasource like datatable etc and bind it to gridview.

If you want to format or change something in grid dynamically then implement rowdatabound event of gridview


这篇关于如何在运行时从文本框向datagrid中添加数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆