Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DataList with CompareValidator?

Reply
Thread Tools

DataList with CompareValidator?

 
 
Scott.Metzger
Guest
Posts: n/a
 
      10-07-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
 
      10-08-2009
On Oct 7, 9:53*pm, Scott.Metzger
<(E-Mail Removed)> 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

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
Entering DataList EditItemTemplate from Outside of the DataList Luis Esteban Valencia ASP .Net 1 01-06-2005 07:32 PM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM
Click event in a datalist to post back datalist properties Steve Lloyd ASP .Net 1 05-26-2004 04:07 AM
DataList in DataList acko bogicevic ASP .Net 2 11-11-2003 08:31 AM
Datalist in Datalist How? Gönen EREN ASP .Net 0 08-22-2003 02:41 PM



Advertisments