.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How to display values from text box into grid view

Posted By: sanjana     Posted Date: March 12, 2012    Points:5   Category :ASP.Net
Hi all,
I am fresher in asp.net. I have entered values in text box. when i clik OK button, values of text box should be displayed in Grid View.after that if i click on save button the values in grid view should store in sql server(backend),also insert, update ,delete operations should be performed and entered record must not be entered again.

Can anyone give a example using templates or any..

Author: Mahesh             
Posted Date: March 12, 2012     Points: 20   

Create a datatable which has columns equal to columns in datagridview when you load page in that case fetch data from db and store it in datatable and bind that datatable to gridview as,

you can fetch data from DB using DataAdapter as,

Dim oConnection As new SqlConnection("connecttion string")
Dim oCommand As New SqlCommand("Query", oConnection)
Dim oDataAdapter As New SqlDataAdapter(oCommand)

from that DataSet getthe table as,

oDatatable = oDataSet.Table("tableName")

DataGridView.DataSource = oDatatable

When you enter data in textbox tand click on button, add data to datatable as,

oDatatable.Column("columnName") = TextBox.text

and again bind data to datagridview as,

DataGridView.DataSource = oDatatable

this will save data in Datatable and when you want to save data in DB then on click of Save button,you can save data in DB as per your requirement, you can create Storedprocedure which will insert data in database or you can execute insert/update/delete queries..

Hope this helps....if any queries get back to me....


Author: Rajesh             
Posted Date: March 12, 2012     Points: 20   

hi use tis code

Download Attachment

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend