question

Tabboz-4089 avatar image
0 Votes"
Tabboz-4089 asked Tabboz-4089 commented

how to automatically check a checkbox from a condition

Good morning,

I have two tables, the first is called [dettaglioMateriale]
112810-tbl-dettmat.jpg

the second is called [fuoriUso]
112911-tbl-fuoriuso.jpg

in the first table I have a checkbox in the "Dismesso" column. I would like this Checkbox to be checked when this condition occurs:
112912-select.jpg

this is the checkbox in the gridview:

 <asp:TemplateField HeaderText="FU" SortExpression="Dismesso">
     <ItemTemplate>
        <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Dismesso") %>' Enabled="false" />
     </ItemTemplate>
 </asp:TemplateField>

I use vb.net, thanks in advance to those who can advise me.



sql-server-generaldotnet-aspnet-general
tbl-dettmat.jpg (45.7 KiB)
tbl-fuoriuso.jpg (38.0 KiB)
select.jpg (60.8 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Maybe try something like this:

select dettaglioMateriale.IDdettaglio, 1 as Dismesso
from dettaglioMateriale inner join .....

Then the Dismesso checkbox (in grid view) will be checked for these items.


0 Votes 0 ·

1 Answer

YijingSun-MSFT avatar image
1 Vote"
YijingSun-MSFT answered Tabboz-4089 commented

Hi @Tabboz-4089 ,
What' your data in your database? When you auto check the checkbox?
I have do a demo that your Dismesso are all false in the database. And when you bind the data to the gridview, the checkbox will auto checked according to the condition.
You could use these sql when binding the data.

 UPDATE dettaglioMateriale
 SET dettaglioMateriale.Dismesso=1
 FROM  dettaglioMateriale INNER JOIN fuoriUso ON dettaglioMateriale.IDdettaglio=fuoriUso.CODdettaglio

Best regards,
Yijing Sun


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @YijingSun-MSFT,

thank you very much for the quick solution. works perfectly!

Have a nice day!

0 Votes 0 ·