PC Review


Reply
Thread Tools Rate Thread

DataList with CompareValidator?

 
 
Scott.Metzger
Guest
Posts: n/a
 
      7th Oct 2009
Hi,

I have a DataList and on the EditTemplaate I have a CompareValidator

I am using an Update_Command for the DataList.
The CompareValidator works fine and displays, however, the Update Command
still fires and attempts to execute the code in the procedure.

How do I check to see if the CompareValidator is 'active' or how do I keep
the Update Command from fireing?

<aspataList ID="listVetMed" runat="server" DataKeyField="eor_supplies_id"
DataSourceID="dsVetMed" BorderStyle="Solid"
OnEditCommand="Edit_Command"
OnCancelCommand="Cancel_Command"
OnDeleteCommand="Delete_Command"
OnUpdateCommand="Update_Command">
....

protected void Update_Command(object sender, DataListCommandEventArgs e)
{
DropDownList ddAnimalList =
(DropDownList)e.Item.FindControl("ddAnimalList");
string eor_supplies_id =
listVetMed.DataKeys[e.Item.ItemIndex].ToString();
Label lblcare_ts_id = (Label)e.Item.FindControl("lblcare_ts_id");
Label lblQuarantineTsId =
(Label)e.Item.FindControl("lblQuarantineTsId");
TextBox txtQty = (TextBox)e.Item.FindControl("txtQty");
DropDownList ddBSLLevel =
(DropDownList)e.Item.FindControl("ddBSLLevel");
DropDownList ddDateNeeded =
(DropDownList)e.Item.FindControl("ddDateNeeded");
TextBox txtNumDays = (TextBox)e.Item.FindControl("txtNumDays");


DBService.UpdateVetMedAnimalPurchase(lblFiscalYear.Text,
eor_supplies_id, lblcare_ts_id.Text,
lblQuarantineTsId.Text,
ddAnimalList.SelectedValue,
txtQty.Text,
ddBSLLevel.SelectedValue, ddDateNeeded.SelectedValue,
txtNumDays.Text);

listVetMed.ShowHeader = true;
listVetMed.EditItemIndex = -1;
listVetMed.DataBind();

}


Thanks,
Scott


 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      8th Oct 2009
On Oct 7, 9:53*pm, Scott.Metzger
<ScottMetz...@discussions.microsoft.com> wrote:
> Hi,
>
> I have a DataList and on the EditTemplaate I have a CompareValidator
>
> I am using an Update_Command for the DataList. *
> The CompareValidator works fine and displays, however, the Update Command
> still fires and attempts to execute the code in the procedure.
>
> How do I check to see if the CompareValidator is 'active' or how do I keep
> the Update Command from fireing?
>
> <aspataList ID="listVetMed" runat="server" DataKeyField="eor_supplies_id"
> DataSourceID="dsVetMed" BorderStyle="Solid"
> * * *OnEditCommand="Edit_Command"
> * * *OnCancelCommand="Cancel_Command"
> * * *OnDeleteCommand="Delete_Command"
> * * *OnUpdateCommand="Update_Command">
> ...
>
> protected void Update_Command(object sender, DataListCommandEventArgs e)
> * * {
> * * * * DropDownList ddAnimalList =
> (DropDownList)e.Item.FindControl("ddAnimalList");
> * * * * string eor_supplies_id =
> listVetMed.DataKeys[e.Item.ItemIndex].ToString();
> * * * * Label lblcare_ts_id = (Label)e.Item.FindControl("lblcare_ts_id");
> * * * * Label lblQuarantineTsId =
> (Label)e.Item.FindControl("lblQuarantineTsId");
> * * * * TextBox txtQty = (TextBox)e.Item.FindControl("txtQty");
> * * * * DropDownList ddBSLLevel =
> (DropDownList)e.Item.FindControl("ddBSLLevel");
> * * * * DropDownList ddDateNeeded =
> (DropDownList)e.Item.FindControl("ddDateNeeded");
> * * * * TextBox txtNumDays = (TextBox)e.Item.FindControl("txtNumDays");
>
> * * * * DBService.UpdateVetMedAnimalPurchase(lblFiscalYear.Text,
> eor_supplies_id, lblcare_ts_id.Text,
> * * * * * * * * * * * * * * * * * * * * * * lblQuarantineTsId.Text,
> ddAnimalList.SelectedValue,
> * * * * * * * * * * * * * * * * * * * * * * txtQty.Text,
> ddBSLLevel.SelectedValue, ddDateNeeded.SelectedValue,
> * * * * * * * * * * * * * * * * * * * * * * txtNumDays.Text);
>
> * * * * listVetMed.ShowHeader = true;
> * * * * listVetMed.EditItemIndex = -1;
> * * * * listVetMed.DataBind();
>
> * * }
>
> Thanks,
> Scott


Add the following code to the start of the UpdateCommand event
handler:

if (!Page.IsValid)
return;
 
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 do you bind a datalist that is inside a bound datalist =?Utf-8?B?QVNQIERldmVsb3Blcg==?= Microsoft ASP .NET 2 26th Sep 2006 03:18 AM
setting SelectedIndex of DataList nested inside of DataList? Les Caudle Microsoft ASP .NET 0 2nd May 2006 11:44 PM
Datalist - How do I make a specific item in a datalist not able to =?Utf-8?B?R3JhZW1l?= Microsoft Dot NET 0 10th Feb 2005 04:29 AM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll Microsoft ASP .NET 8 9th Sep 2004 11:13 PM
Click event in a datalist to post back datalist properties Steve Lloyd Microsoft ASP .NET 1 26th May 2004 05:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:51 AM.