
Originally Posted by
micky
Hmm, i was also thinking of that........... let me see if i can write that query

Ok, i got it.
Posting my existing working code
added this line in datagrid in .aspx file
Code:
<asp:BoundColumn Visible="False" DataField="bPresent" ReadOnly="True"></asp:BoundColumn>
Then this query to load the datagrid
Code:
Dim strSQL As String = "Select Count(SI.Item_Id) as bPresent, I.Item_Id, I.Item_Name, I.Item_Price From tblitemmaster as I " & _
"Left Join tblstoreitemdetails as SI on I.Item_Id=SI.Item_Id and SI.Store_Id=@StoreId " & _
"Where I.Category_Id=@CategoryId Group By I.Item_Id"
Then in datagrid's item data bound event to check the checkbox
Code:
Protected Sub dgItem_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgItem.ItemDataBound
If (e.Item.ItemType = ListItemType.Item) Or (e.Item.ItemType = ListItemType.AlternatingItem) Then
Dim cb As CheckBox = e.Item.Cells(4).Controls(1)
Dim intRecord As Integer = e.Item.Cells(5).Text.ToString
If intRecord = 1 Then
cb.Checked = True
Else
cb.Checked = False
End If
End If
End Sub
Bookmarks