Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying Foreach Results in DataGrid

Status
Not open for further replies.

GavW

Programmer
Jan 13, 2006
58
GB
Hey all i am pretty new to using C# i am attempting to display all records from a database table (tblDraw) where the "Ball1" field matches the value of my "tx1stBall" textbox. Am sure one of you should not have a hard time with this one.

The following code writes out all of the usernames in the table whose "Ball1" field matches. I would like to display the entire record of all those that match in a datagrid (DataGrid4)

Help very much appreciated.


foreach(DataRow mydataRow in dsDraw1.Tables["tblDraw"].Rows)
{
if (tx1stBall.Text == mydataRow["Ball1"].ToString())
{
Response.Write(mydataRow["Username"].ToString());
}
}
 
hi,
your wokring very hard to do a simple thing,

you have a few options here

read up on Dataview and DataTable.select

hth

Bassguy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top