PC Review


Reply
Thread Tools Rate Thread

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

 
 
=?Utf-8?B?UGxheW1ha2Vy?=
Guest
Posts: n/a
 
      8th Aug 2005
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!
 
Reply With Quote
 
 
 
 
Brock Allen
Guest
Posts: n/a
 
      8th Aug 2005
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!
>




 
Reply With Quote
 
=?Utf-8?B?UGxheW1ha2Vy?=
Guest
Posts: n/a
 
      8th Aug 2005
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!!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to put a GridView's row in edit mode, programatically? ata@mailinator.com Microsoft ASP .NET 4 6th Jun 2008 08:26 PM
How to tell if gridview row is in edit mode JJ Microsoft ASP .NET 1 8th Jun 2007 05:30 PM
GridView Edit Mode in ASP.NET 2.0 Sridhar.Ammula@gmail.com Microsoft ASP .NET 1 16th Oct 2006 06:35 PM
Gridview and EmptyDataTemplate in Edit mode j-in-uk Microsoft C# .NET 0 21st Jul 2006 12:53 AM
ASP.net 2.0 GridView edit mode problems tfsmag Microsoft ASP .NET 6 9th Jan 2006 02:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:23 AM.