how to automatically check a checkbox from a condition

Tabboz 41 Reputation points
2021-07-08T06:51:22.697+00:00

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.

Developer technologies ASP.NET Other
SQL Server Other
{count} votes

Accepted answer
  1. Yijing Sun-MSFT 7,096 Reputation points
    2021-07-08T08:30:13.927+00:00

    Hi @Tabboz ,
    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 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.