By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,028 Members | 1,108 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,028 IT Pros & Developers. It's quick & easy.

Datagrid validation

P: n/a
Hey all,

I'm trying to implement validation in my asp.net datagrid. For example, if a
user enters in a Customer ID I want it to check a different data table to see
if the customer exists.

I'm assuming I'll have to use template columns to add the custom validation
control next to each textbox. Please correct me if I'm wrong because i'm
having a challenging time with template columns.

Here's my question: I've noticed an issue between using template columns and
the regular bound columns. The way the textbox is accessed thru code:

Bound Column access to textbox
Cells(2).Controls(0)

Template Column access to textbox
Cells(2).Controls(1)

Why is there a difference?

thanks,
rodchar
Nov 18 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi rodchar:

It all depends on what HTML these controls generate. I've always shied
away from indexing into the Controls array, because I imagine at some
point in the future the functionality might change and the controls
won't be at that position anymore (or I might decide to change the
layout, too). I've been using the Control.FincControl method on
DataGrid item to locate any server side controls I want to inspect ro
change from code.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 14 Oct 2004 08:43:03 -0700, "rodchar"
<ro*****@discussions.microsoft.com> wrote:
Hey all,

I'm trying to implement validation in my asp.net datagrid. For example, if a
user enters in a Customer ID I want it to check a different data table to see
if the customer exists.

I'm assuming I'll have to use template columns to add the custom validation
control next to each textbox. Please correct me if I'm wrong because i'm
having a challenging time with template columns.

Here's my question: I've noticed an issue between using template columns and
the regular bound columns. The way the textbox is accessed thru code:

Bound Column access to textbox
Cells(2).Controls(0)

Template Column access to textbox
Cells(2).Controls(1)

Why is there a difference?

thanks,
rodchar


Nov 18 '05 #2

P: n/a
rodchar, ditto: you'll make yourself crazy if you don't use findcontrol.

"Scott Allen" wrote:
Hi rodchar:

It all depends on what HTML these controls generate. I've always shied
away from indexing into the Controls array, because I imagine at some
point in the future the functionality might change and the controls
won't be at that position anymore (or I might decide to change the
layout, too). I've been using the Control.FincControl method on
DataGrid item to locate any server side controls I want to inspect ro
change from code.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 14 Oct 2004 08:43:03 -0700, "rodchar"
<ro*****@discussions.microsoft.com> wrote:
Hey all,

I'm trying to implement validation in my asp.net datagrid. For example, if a
user enters in a Customer ID I want it to check a different data table to see
if the customer exists.

I'm assuming I'll have to use template columns to add the custom validation
control next to each textbox. Please correct me if I'm wrong because i'm
having a challenging time with template columns.

Here's my question: I've noticed an issue between using template columns and
the regular bound columns. The way the textbox is accessed thru code:

Bound Column access to textbox
Cells(2).Controls(0)

Template Column access to textbox
Cells(2).Controls(1)

Why is there a difference?

thanks,
rodchar


Nov 18 '05 #3

P: n/a
thanks for the tips everyone. i really appreciate it.

"rodchar" wrote:
Hey all,

I'm trying to implement validation in my asp.net datagrid. For example, if a
user enters in a Customer ID I want it to check a different data table to see
if the customer exists.

I'm assuming I'll have to use template columns to add the custom validation
control next to each textbox. Please correct me if I'm wrong because i'm
having a challenging time with template columns.

Here's my question: I've noticed an issue between using template columns and
the regular bound columns. The way the textbox is accessed thru code:

Bound Column access to textbox
Cells(2).Controls(0)

Template Column access to textbox
Cells(2).Controls(1)

Why is there a difference?

thanks,
rodchar

Nov 18 '05 #4

P: n/a
what would be the textbox id if the columns are auto-generated?

"Scott Allen" wrote:
Hi rodchar:

It all depends on what HTML these controls generate. I've always shied
away from indexing into the Controls array, because I imagine at some
point in the future the functionality might change and the controls
won't be at that position anymore (or I might decide to change the
layout, too). I've been using the Control.FincControl method on
DataGrid item to locate any server side controls I want to inspect ro
change from code.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 14 Oct 2004 08:43:03 -0700, "rodchar"
<ro*****@discussions.microsoft.com> wrote:
Hey all,

I'm trying to implement validation in my asp.net datagrid. For example, if a
user enters in a Customer ID I want it to check a different data table to see
if the customer exists.

I'm assuming I'll have to use template columns to add the custom validation
control next to each textbox. Please correct me if I'm wrong because i'm
having a challenging time with template columns.

Here's my question: I've noticed an issue between using template columns and
the regular bound columns. The way the textbox is accessed thru code:

Bound Column access to textbox
Cells(2).Controls(0)

Template Column access to textbox
Cells(2).Controls(1)

Why is there a difference?

thanks,
rodchar


Nov 18 '05 #5

P: n/a
If you call find control on the DataGridItem (the row), the TextBox
ID will be the same as the ID the textbox has in the markup.

I have an article that explains this in detail:
http://odetocode.com/Articles/116.aspx

HTH,
--
Scott
http://www.OdeToCode.com/

On Fri, 15 Oct 2004 12:29:09 -0700, "rodchar"
<ro*****@discussions.microsoft.com> wrote:
what would be the textbox id if the columns are auto-generated?

"Scott Allen" wrote:
Hi rodchar:

It all depends on what HTML these controls generate. I've always shied
away from indexing into the Controls array, because I imagine at some
point in the future the functionality might change and the controls
won't be at that position anymore (or I might decide to change the
layout, too). I've been using the Control.FincControl method on
DataGrid item to locate any server side controls I want to inspect ro
change from code.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 14 Oct 2004 08:43:03 -0700, "rodchar"
<ro*****@discussions.microsoft.com> wrote:
>Hey all,
>
>I'm trying to implement validation in my asp.net datagrid. For example, if a
>user enters in a Customer ID I want it to check a different data table to see
>if the customer exists.
>
>I'm assuming I'll have to use template columns to add the custom validation
>control next to each textbox. Please correct me if I'm wrong because i'm
>having a challenging time with template columns.
>
>Here's my question: I've noticed an issue between using template columns and
>the regular bound columns. The way the textbox is accessed thru code:
>
>Bound Column access to textbox
>Cells(2).Controls(0)
>
>Template Column access to textbox
>Cells(2).Controls(1)
>
>Why is there a difference?
>
>thanks,
>rodchar



Nov 18 '05 #6

P: n/a
awesome, thank you so much.

"Scott Allen" wrote:
If you call find control on the DataGridItem (the row), the TextBox
ID will be the same as the ID the textbox has in the markup.

I have an article that explains this in detail:
http://odetocode.com/Articles/116.aspx

HTH,
--
Scott
http://www.OdeToCode.com/

On Fri, 15 Oct 2004 12:29:09 -0700, "rodchar"
<ro*****@discussions.microsoft.com> wrote:
what would be the textbox id if the columns are auto-generated?

"Scott Allen" wrote:
Hi rodchar:

It all depends on what HTML these controls generate. I've always shied
away from indexing into the Controls array, because I imagine at some
point in the future the functionality might change and the controls
won't be at that position anymore (or I might decide to change the
layout, too). I've been using the Control.FincControl method on
DataGrid item to locate any server side controls I want to inspect ro
change from code.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 14 Oct 2004 08:43:03 -0700, "rodchar"
<ro*****@discussions.microsoft.com> wrote:

>Hey all,
>
>I'm trying to implement validation in my asp.net datagrid. For example, if a
>user enters in a Customer ID I want it to check a different data table to see
>if the customer exists.
>
>I'm assuming I'll have to use template columns to add the custom validation
>control next to each textbox. Please correct me if I'm wrong because i'm
>having a challenging time with template columns.
>
>Here's my question: I've noticed an issue between using template columns and
>the regular bound columns. The way the textbox is accessed thru code:
>
>Bound Column access to textbox
>Cells(2).Controls(0)
>
>Template Column access to textbox
>Cells(2).Controls(1)
>
>Why is there a difference?
>
>thanks,
>rodchar


Nov 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.