G
Guest
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 cicmdPerformSearch_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
if (this.dgSearchAddresses.Items.Count == 0)
{
ArrayList addresses;
addresses = (ArrayList) ViewState["Addresses"];
Context.Items["TransferAddresses"] = addresses;
Server.Transfer("../Internet/WebForm2.aspx");
}
else
{
pnlMessages.Visible = true;
this.lblMessage.Text = "You must select at least one address";
}
}
Cheers again for any help anyone can give.
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 cicmdPerformSearch_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
if (this.dgSearchAddresses.Items.Count == 0)
{
ArrayList addresses;
addresses = (ArrayList) ViewState["Addresses"];
Context.Items["TransferAddresses"] = addresses;
Server.Transfer("../Internet/WebForm2.aspx");
}
else
{
pnlMessages.Visible = true;
this.lblMessage.Text = "You must select at least one address";
}
}
Cheers again for any help anyone can give.