how we validate data in template column textboxes?

H

Hemant

Hi
Can anyone know how to validate data in textbox which is
in template column?
I have one textbox and one calendar control in template
column. I want to add calendar control's date in textbox
but It says control not found as Id's of control not
matching as it is generated by ASP. net page. If I give ID
to control its taking Datagrid:ctrl_1:my control id
How to access this data?

Please reply its urgent.

Hemant Dhadnekar
Software Engineer II
FreeMarkets Services Pvt. Ltd.
10th Floor, DLF Gateway Tower
R-Block, Phase-III, DLF City
Gurgaon - 122002, Haryana
Ph: 91-124-2357171 Extn. 7214
Mobile -: - 9422310849
 
T

Teemu Keiski

You would need to specify in which DataGrid's Item you are actually setting
the date. That means accessing the DataGrid's Items collection with the
index of the item and then looking for the TextBox and so on.

Other thing is that you'd might want to use so-called popup calendar. Take a
look at following article:
http://www.aspalliance.com/Colt/Articles/Article4.aspx

And third, if you want to let user typing the date and validate that, you'd
put a CompareValidator with Operator="DataTypeCheck" and Type="Date" in the
same TemplateColumn where the TextBox is and specify into it's
ControlToValidate property the ID of the TextBox. This way you could
validate user input.

--
Teemu Keiski
MCP,Designer/Developer
Mansoft tietotekniikka Oy
http://www.mansoft.fi

AspInsiders Member, www.aspinsiders.com
ASP.NET Forums Moderator, www.asp.net
AspAlliance Columnist, www.aspalliance.com
 
T

Teemu Keiski

That Datagrid:ctrl_1:txt1 is UniqueID that the DataGrid and DataGridItem
creates for the control as they are naming containers. Inside the naming
container txt1 is valid ID for the control (that is the task naming
container makes does). ControlToValidate expects the same ID that you
explicitly give for the TextBox in the same TemplateColumn or row at least
(i.e both validator and TextBox need to be in same DataGridItem and you give
the TextBox the ID and assign that to ControlToValidate property)

Show the aspx how you have declared the validator and the TextBox.

--
Teemu Keiski
MCP,Designer/Developer
Mansoft tietotekniikka Oy
http://www.mansoft.fi

AspInsiders Member, www.aspinsiders.com
ASP.NET Forums Moderator, www.asp.net
AspAlliance Columnist, www.aspalliance.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top