0

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.