hi hope you all ok. this block is in a for each statement.

TextBox tb = new TextBox();
                    tb.Text = rowData[key];
                    cell.Controls.Add(tb);

I need these textboxes (which are created at runtime) to be required user entry fields. Bear in mind i know how to do this with asp.net, I am trying to do it in c#. thanks for your time!

did you tried to add (at runtime) RequireFieldValidator for any textbox previously created?

do you mean ?

RequiredFieldValidator reqFieldValid = new RequiredFieldValidator();
                    TextBox tb = new TextBox();
                    tb.Text = rowData[key];
                    cell.Controls.Add(tb);
                    tb.Controls.Add(reqFieldValid);

yup. something like that. but you also have to set the ControlToValidate property.
Now ... i have no idea if you can do reqFieldValid.ControlToValidate = tb or first you have to use FindControl ... to get your textbox.

in for loop only create required field validators.and for each text box give

tb.id=somevalue(btr to use int so that u can increment);
rf.controltovalidate=somevalue;

i think it will work.let me know it iam correct or not.thank you,
-srikanth kadem

thanks very much for your help I will keep you informed if I get it working! cheers!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.