Hey everyone,
I am trying to run some validation on the on-click event of a button to
check and see whether a datagrid contains any rows inserted into it and if it
does then I'd like it to work as normal. However if it has no items in it
then i'd like it to display the error message below and not move forward.
Here is the code I have but it doesn't seem to work. I think i've got the
wrong logic. Can someone help me work this out.
Thanks
private void cicmdPerformSea rch_Click(objec t sender,
System.Web.UI.I mageClickEventA rgs e)
{
if (this.dgSearchA ddresses.Items. Count == 0)
{
ArrayList addresses;
addresses = (ArrayList) ViewState["Addresses"];
Context.Items["TransferAddres ses"] = addresses;
Server.Transfer ("../Internet/WebForm2.aspx") ;
}
else
{
pnlMessages.Vis ible = true;
this.lblMessage .Text = "You must select at least one address";
}
}
Cheers again for any help anyone can give. 2 1982
Hi,
Please remember that teh grid is only a way to show the content of a
collection of some kind in the page, with this I mean that it does not
contains data by itself.
Are you trying to see if the binded collection has any item at all?
Do you keep a reference to the data source used to bind the grid? if so that
is what you need to query about insertions, etc
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Stephen" <St*****@discus sions.microsoft .com> wrote in message
news:01******** *************** ***********@mic rosoft.com... Hey everyone, I am trying to run some validation on the on-click event of a button to check and see whether a datagrid contains any rows inserted into it and if
it does then I'd like it to work as normal. However if it has no items in it then i'd like it to display the error message below and not move forward. Here is the code I have but it doesn't seem to work. I think i've got the wrong logic. Can someone help me work this out. Thanks
private void cicmdPerformSea rch_Click(objec t sender, System.Web.UI.I mageClickEventA rgs e) { if (this.dgSearchA ddresses.Items. Count == 0) { ArrayList addresses; addresses = (ArrayList) ViewState["Addresses"]; Context.Items["TransferAddres ses"] = addresses; Server.Transfer ("../Internet/WebForm2.aspx") ; } else { pnlMessages.Vis ible = true; this.lblMessage .Text = "You must select at least one address"; } } Cheers again for any help anyone can give.
Are you trying to see if the binded collection has any item at all?
Yes
The datagrid is binded to the addresses arraylist which is saved in the
viewstate object.
I know it doesn't contain data unless it is bound to something, but im
trying to figure out if it contains any rows and if it doesn't I don't want
the user to be able to move forward to a different page as the user must have
a least one row or the search is going to crash.
"Ignacio Machin ( .NET/ C# MVP )" wrote: Hi,
Please remember that teh grid is only a way to show the content of a collection of some kind in the page, with this I mean that it does not contains data by itself. Are you trying to see if the binded collection has any item at all? Do you keep a reference to the data source used to bind the grid? if so that is what you need to query about insertions, etc
Cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation "Stephen" <St*****@discus sions.microsoft .com> wrote in message news:01******** *************** ***********@mic rosoft.com... Hey everyone, I am trying to run some validation on the on-click event of a button to check and see whether a datagrid contains any rows inserted into it and if it does then I'd like it to work as normal. However if it has no items in it then i'd like it to display the error message below and not move forward. Here is the code I have but it doesn't seem to work. I think i've got the wrong logic. Can someone help me work this out. Thanks
private void cicmdPerformSea rch_Click(objec t sender, System.Web.UI.I mageClickEventA rgs e) { if (this.dgSearchA ddresses.Items. Count == 0) { ArrayList addresses; addresses = (ArrayList) ViewState["Addresses"]; Context.Items["TransferAddres ses"] = addresses; Server.Transfer ("../Internet/WebForm2.aspx") ; } else { pnlMessages.Vis ible = true; this.lblMessage .Text = "You must select at least one address"; } } Cheers again for any help anyone can give. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Hi |
last post by:
I have a ASP.Net page that has a few fields to submit to a database and a
datagrid to edit the entries. I have validation controls to make sure the
user enters the right info on the first few fields.
In the datagrid, I have it set up dynamic so they can edit the dtabase
records from the database. They click edit and they can edit a few fields and
then press either update or cancel.
The problem I have now is that when the user presses...
|
by: Stephen |
last post by:
I have two datagrids on a page and each of them allow the user to add rows.
On each datagrid I have validation (required field, reg expressions etc) and
my problem is that I only want the validation to work on the datagrid which I
click add in. At the moment if I click add in one datagrid and haven;t
filled out anything on the other datagrid then the validation comes up. Does
any one know what I can do to combat this?
|
by: Ben |
last post by:
Hi, I have a page with a datagrid that you have to scroll to see. I'm using
the StrengthControls SmartScroller as recommended to maintain my scroll
position.
Anyway, inside the datagrid I have fields that require validation. No
problem, I put the validators on them and they work just fine... Except for
the fact that when a user has an invalid entry and fires a validation event
client side the scroll position is reset to the top of the...
|
by: rodchar |
last post by:
Hey all,
I've got an asp.net page that has a textbox on it. The textbox has a
requiredfieldvalidation associated with it.
I've also got a datagrid with the edit,update,cancel links on it. When I run
my app, and select the update link on the datagrid my textbox validation
fires. Not sure why?
Note: if i close the application and restart it it works fine. no error.
|
by: Chris |
last post by:
Based upon some prevoius postings on what to do for adding a 'add' row to a
datagrid I utilize the footer to create the 'add' row. The only issue is that
I have it sharing the 'UpDate_Command' and I use an argument to difference
between an 'edit' vs. and 'add. But since I have field validation on both
'footer' and 'edit' columns I can't submit my edits since the footer
validation kicks in.If I take the validation off then the both work fine...
| |
by: David Colliver |
last post by:
Hi all,
I am having a slight problem that hopefully, someone can help me fix.
I have a form on a page. Many items on the form have validation controls
attached.
Also on this form are linkbuttons which must not cause validation. I have
found a setting "causeValidation" to disable the validation.
Also on the page, I have a datagrid that I will edit lines on. I can click
|
by: Kris |
last post by:
Hi,
I have a DataGrid where in each row has couple of text boxes and an
update button. Each row is dynamically generated as the number of rows
are not known ahead of time. When the user clicks the update button, I
do a postback to capture the data entered. However I dont want to do a
postback when the textboxes are empty. How do I prevent this using
Clientside validation? This is a common problem and if it has been
beaten to death, please...
|
by: rmccinc |
last post by:
OK, I am running into some issues that I cant figure out a work-around.
I am not going to post code cause I figured out WHY my issue is
happening:
-I have a datagrid, and a button that fires a click event.
-The Datagrids onitemdatabound event dynamically creates validation
controls per values from other columns in the datagrid, one of those
controls is a textbox and it is the ControlToValidate of the validation
control.
|
by: Tina |
last post by:
the Edit, Update, Cancel, and Delete buttons in my datagrid are causing
validation elsewhere on the page. I want to specify that these buttons
should not cause validation but they have no design time property of
causevalidation.
How can I keep them from causing validation?
Thanks,
T
|
by: Peter Afonin |
last post by:
Hello,
I'm not an expert in Javascript, so I'm seeking an advice.
As I mentioned in my previous post, I use Javascript to check whether at
least one checkbox in the datagrid has been checked. I have to use
Stringbuilder to do this:
Dim iCount As Int32
Dim sClientSideValidate As New StringBuilder
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |