Live Chat Icon For mobile
Live Chat Icon

How to enable or disable the button in the DataGrid based on a bit value in the database

Platform: ASP.NET| Category: DataGrid

<asp:DataGrid id='DataGrid1' runat='server'>
<asp:TemplateColumn HeaderText ='Product Information' >
<ItemTemplate >
<asp:Button CommandName='Status' Text ='Status' Runat =server  
	Enabled =<%#CheckStatus(Convert.ToBoolean(DataBinder.Eval(Container.DataItem,'Discontinued')))%> ID='Button1' >


Protected Function CheckStatus(ByVal prdStatus As Boolean) As Boolean
	If prdStatus = False Then
		Return True
		Return False
	End If
End Function


protected bool CheckStatus(bool prdStatus)
	//If the Discontinued field is '0'
	if (prdStatus==false)
		return true;
	//If the Discontinued field is '1'
		return false;

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.