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!

Comparing data in a datagrid to values in textboxes

Status
Not open for further replies.

JaneB19

Technical User
Jun 27, 2002
110
GB
Hi,

I'm hoping that somebody can help me out?!

What I am tring to do is compare values in a set of dynamically created textboxes (1 character per textbox) to data in a datagrid. The data is the result of a query, so it's being pulled from a database.

I hope I making sense?

Does anybody know of a solution to my problem?

The textboxes are held in a placeholder, and are generated depending on the value of the selected radioButton in a radioButtonList.

My coding for the textBoxes is as follows:

For ctr = 1 To No_Letters.SelectedValue Step 1

'Genereate Text Box
tmpTxtBox.ID = "txtBox" & ctr

'Add text box to placeholder
PlaceHolder1.Controls.Add(tmpTxtBox)

Next


I'd give you my SQL coding but it's FAR too long! I had thought about putting the relevant coding in the SQL but I reckon it wouldn't work, and that it would be too complicated to implement!

Is there a COMPARE attribute that I can use? Like DataGrid.Compare(txtBox.text)

Thanks in advance
Jane :)
 
Assuming everything is built correctly on Page.Load, just reference the TextBox control's Text property, and compare it to the Text property of the cell on the DataGrid.ItemDataBound event (assuming you're binding data on PostBack).
 
Hi BoulderBum,

Thanks for your reply.

I was wondering if it would still be possible to do a 'comparison' if the data in the dataGrid wasn't bound? i.e. the dataGrid doesn't have column headings (as the data is pulled from different tables depending on earlier selections in the form).

I was trying out your advice (but amending it a wee bit) so that it became:

If "boxID1".Text = AdvancedSolutions1.DataSource Then
AdvancedSolutions2.DataBind
Next

although I'm not too sure how I could reference one DataGrid cell into another DataGrid. There would be more in the If statement as I'd have to compare each given letter in the textbox (depending on there being one).

My idea was that I pulled all the possible solutions into the 1st dataGrid and then displayed the compared data in the 2nd dataGrid.

This seems to get more and more complicated each time I explain it.

Hope that you can help :)

Thanks again
Jane :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top