By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,028 Members | 894 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.

ASP.NET 2.0 Whidbey, Customizing the Edit/Insert mode for GridView

P: n/a
Hopefully someone else has come across this issue.

What I have is a SQL Server 2000 back-end. I've created a simple webform
which has both Gridview and DataList controls on it populated with a
SqlDataSource. Okay, simple enough, that all works fine. I have also
enabled inserting and editing on these controls. This is a very cool feature
of 2.0 and it works quite well. Functionally I am able to do everything such
as inserting and editing, so I know that everything is setup correctly. What
I want to do now is validation...

When a user uses the control, they click on "New", the control is changed
into insert mode, and empty text boxes are presented. The fill in what they
want and click on insert. But how can I implement validation? There is
nothing I can find to prevent a user from putting text into an integer field
and trying to insert it. Of course if they do that a SQL exception will be
thrown. I know how to handle the exception and give an error, but I feel
that is too late in the process. I would like to do regular validation just
like on a simple web form. Is there a way to edit the insert mode of these
controls? Both visually and programmatically?

Also, let's say I want to replace a textbox with a dropdownlist in the
insert mode, can this be done? Surely someone else has thought of this, or
am I just expecting too much out of these controls?

Thanks in advance! If you need anything clarified or some code please let
me know!
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You can setup different sets of validator controls using the ValidationGroup
property -- this way you can have different validators for InsertMode and
UpdateMode.

http://beta.asp.net/QUICKSTART/aspne...lidationgroups

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hopefully someone else has come across this issue.

What I have is a SQL Server 2000 back-end. I've created a simple
webform which has both Gridview and DataList controls on it populated
with a SqlDataSource. Okay, simple enough, that all works fine. I
have also enabled inserting and editing on these controls. This is a
very cool feature of 2.0 and it works quite well. Functionally I am
able to do everything such as inserting and editing, so I know that
everything is setup correctly. What I want to do now is validation...

When a user uses the control, they click on "New", the control is
changed into insert mode, and empty text boxes are presented. The
fill in what they want and click on insert. But how can I implement
validation? There is nothing I can find to prevent a user from
putting text into an integer field and trying to insert it. Of course
if they do that a SQL exception will be thrown. I know how to handle
the exception and give an error, but I feel that is too late in the
process. I would like to do regular validation just like on a simple
web form. Is there a way to edit the insert mode of these controls?
Both visually and programmatically?

Also, let's say I want to replace a textbox with a dropdownlist in the
insert mode, can this be done? Surely someone else has thought of
this, or am I just expecting too much out of these controls?

Thanks in advance! If you need anything clarified or some code please
let me know!


Nov 19 '05 #2

P: n/a
Wonderful, but I'm still not quite there. I have used the validation groups
and am familiar with how they work and I'm sure I can make them do what I
need to. I still have the problem of editing these modes. How can I step
into the Edit/Insert modes of these controls so I can edit them. Similar to
how you can convert the Login control to a template and then make any changes
you want. That way I can add the validation controls and assign them to a UI
control.

I must be missing something??? Hopefully I am making sense of what I am
trying to do.

Thanks for the quick response!!
Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.