Showing posts with label checkbox. Show all posts
Showing posts with label checkbox. Show all posts

Wednesday, March 28, 2012

If Else Statement in a Update Trigger

I am trying to build an update trigger to check the condition if checkbox is true then add 1 year, else add 3 years. The code works before i added the if checkbox = true.

Original Working code:

IF NOT UPDATE (EDITED)

UPDATE drvisit

SET nextvisit = dateadd (yy, 1, lastaudio)

FROM Apt

WHERE rec# IN (SELECT rec# FROM inserted)

Code I am trying to use with an IF Statement:

IF NOT UPDATE (EDITED)

UPDATE drvisit

IF Checkbox = True

SET nextvisit = dateadd (yy, 1, lastaudio)

FROM Apt

WHERE rec# IN (SELECT rec# FROM inserted)

Else

Set nextvisit = dateadd (yy, 3, lastaudio)

FROM Apt

WHERE rec# IN (SELECT rec# FROM inserted)

Use a case statement instead of "IF"
This example assumes "checkbox" is a bit field...

IF NOT UPDATE (EDITED)

UPDATE drvisit
SET nextvisit = case when checkbox = 1 then dateadd (yy, 1, lastaudio) else dateadd (yy, 3, lastaudio) end
FROM Apt
WHERE rec# IN (SELECT rec# FROM inserted)

|||Sweet thanks.. If i did want to do and if statement how would I? On a few occasions I tried it and could never get it to work.|||

Glad to be of help.

"IF" is really only for controlling the flow of execution of your SQL script. It can't be used within a single SQL statement (like UPDATE) to conditionally apply a value.

Sunday, February 19, 2012

Identifying the servercontrol in repeater

Hell Sir,

I am using repeater control to show the result after search .and using checkbox control in itemtemplate row .After searchresult i am facing a problem in identifying the checked checkboxes in the itemtemplate of repeater control .

Please provide appropriate solution ...

thanks for ur attention...

Hi,

take a look at this article: the technique's similar for repeaters:Using a comma delimited string with id's as input parameter for a SQL query. But if I remember correctly you shouldn't loop the Rows but Items instead.

Grz, Kris.

|||

Hello sir

i am asking about the repeater control

please forward the solution in case of repeater control

|||

Hi,

In your code-behind file, try to use FindControl to get the checkbox on your page.See the following sample.

for (int i = 0; i <this.Repeater1.Items.Count; i++) {bool ifchecked=(Checkbox(this.Repeater1.Items[i].FindControl("Checkbox1"))).Checked;}
Hope that helps. Thanks.