954,202 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Passing parameter to datagridview

Hi all,
I need help in passing parameter value to a datagridview control on my form. I have a form with a textbox control, a datagridview control and a button. When the user enters in the title of a movie in the textbox and clicks on the OK button, I would like that record to be retrieved from the database into the datagridview control. The datagridview is bound to a database table. Can someone please help. Sample code will be greatly appreciated.

Regards

olodu
Newbie Poster
4 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

what your asking is a pretty easily completed task. what you need to do make a new select statement with a user defined variable. see below

Select MovieId, MovieTitle, MovieDesc
From Movies
Where MovieTitle = <strong>@myTitle</strong>

that @myTitle tells the TableAdapter that the value of @myTitle will be sent in, meaning it can be the text value of the text box. once you have created this new query you can then create a grid view from it, during the creation of the grid view it will ask you to assign any user defined parameters. select control as the type, and then the name of the text box as the value. should work easy enough.

hope that helps.

mike.mclennan
Light Poster
45 posts since May 2007
Reputation Points: 39
Solved Threads: 0
 

Hi All,

I need help in passing data from a datagridview control to textboxes control. When the user doubleclick a value from a datagridview control in form1, I want the record to be displayed in the texboxes of form2. How do I go about coding this? Any help would be highly welcome.

olodu
Newbie Poster
4 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

Hi, I have created the following sql statement in tblshopstableadapter:

SELECT ShopID, CategoryID, ShopName, Floor
FROM tblShops
WHERE (ShopName = '@Name')

How do i assign a data in a text box to @name ?

Fritzeh
Newbie Poster
11 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You