I am using Dynamic SQl in my stored Procedure. In front end I am using C#.net gridview to display the data.
I have three fields in my Table,
1) Active- Bit 2) DateMadeInactive-smallDate 3)Comments-Varchar(Max)
Depending on the condition of the active Value I have to display those three or two fields in the gridview.
If Active= true, Then I have to display active and Comments.
If Active =false, Then I have to DateMadeInactive and Comments Fields.
For Rendering the Active field I am using the following
<asp:TemplateField HeaderText="Comments" SortExpression="Comments" >
<ItemTemplate>
<%#Eval("Comments")%>
</ItemTemplate>
</asp:TemplateField>
In my stored Procedure I am checking Like this开发者_如何学编程 for null, if its null then I am displaying as false
set @SQLQuery = @SQLQuery+ ',isnull(Register.Active,''0'')as Active,
Could anybody tell me where do I check for the Active value or Is there any method in SQL which Checks for the True/False condition of the field.
I am not expecting complete answer, just a hint only...
Thank you.
Hari
The GridView.RowDataBound event is what you're looking for.
When handling the event check the value of the field and show or hide your controls accordingly.
Beware: You can't hide the whole column, as it affects every row, you must show or hide the controls inside the column.
精彩评论