locked
asp.net grid view conditions RRS feed

  • Question

  • User-1683022223 posted

    hello . i have problem conditions 

    if  A-group  = vacationdata

       B-group = dateorder

     <asp:Label ID="lblBoxDate3" runat="server" Viaible='<%# String.Format("{0} - {1}", Eval("namevacation").ToString() == "A-group" ? true : false , Eval("vacationdata" , "{0:yyyy/MM/dd}"))%>'></asp:Label>


    <asp:Label ID="lblBoxDate31" runat="server" Viaible='<%# String.Format("{0} - {1}", Eval("namevacation").ToString() == "B-group" ? true : false , Eval("dateorder" , "{0:yyyy/MM/dd}"))%>'></asp:Label>

    Friday, January 15, 2021 11:10 PM

Answers

  • User-1683022223 posted

    sir thanks for replay

    you mean Visible property >?

    yes its by namevacation if this A-Group or B-Group

    anyway i fix it now its working very well

     <asp:Label ID="lblBoxDate3" runat="server" Text='<%# Eval("vacationdata", "{0:yyyy/MM/dd}")%>'  Visible='<%# Eval("namevacation").ToString() == "A-group" ? true : false %>'></asp:Label>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, January 16, 2021 11:29 AM
  • User-943250815 posted

    You almost there, place both labels on same itemtemplate and make a small ajustment on Visible property

    <asp:TemplateField HeaderText="A/B-gorup">
      <ItemTemplate>
        <asp:Label ID="lblBoxDate3" runat="server" Text='<%# Eval("vacationdata","{0:ddd yyyy/MM/dd}") %>' Visible='<%# Eval("namevacation").ToString() == "A-group" ? true : false%>'></asp:Label>
        <asp:Label ID="lblBoxDate31" runat="server" Text='<%# Eval("dateorder","{0:ddd yyyy/MM/dd}") %>' Visible='<%# Eval("namevacation").ToString() == "B-group" ? true : false%>'></asp:Label>
      </ItemTemplate>
      <ItemStyle HorizontalAlign="Center"></ItemStyle>
    </asp:TemplateField>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, January 16, 2021 11:45 AM

All replies

  • User-1545767719 posted

    <asp:Label ID="lblBoxDate3" runat="server" Viaible='<%# String.Format("{0} - {1}", Eval("namevacation").ToString() == "A-group" ? true : false , Eval("vacationdata" , "{0:yyyy/MM/dd}"))%>'></asp:Label>

    What is the Viaible property you put in the Label control above?

    Is it a typo of Visible? If so, it does not make sense as it accept only bool. 

    Saturday, January 16, 2021 1:21 AM
  • User-1683022223 posted

    am trying merge both column in one

    so... if  namevacation is A-group , i want show only

    this is my old  grid view working good

    <asp:TemplateField HeaderText="A-gorup">
                        <ItemTemplate>
                            <asp:Label ID="lblBoxDate3" runat="server" Text='<%# Eval("vacationdata","{0:ddd yyyy/MM/dd}") %>'></asp:Label>
                        </ItemTemplate>
                        <ControlStyle Width="70px" />
                        <ItemStyle Width="70px" HorizontalAlign="Center"></ItemStyle>
                    </asp:TemplateField>
    
    <asp:TemplateField HeaderText="B-group">
                        <ItemTemplate>
                            <asp:Label ID="lblBoxDate31" runat="server" Text='<%# Eval("dateorder","{0:ddd yyyy/MM/dd}") %>'></asp:Label>
                        </ItemTemplate>
                        <ControlStyle Width="70px" />
                        <ItemStyle Width="70px" HorizontalAlign="Center"></ItemStyle>
                    </asp:TemplateField>

                 

     <asp:TemplateField HeaderText="vacations">
                        <EditItemTemplate>
                            <asp:DropDownList ID="txtDropDownListVaca" runat="server" SelectedValue='<%# Bind("namevacation") %>'>
                                <asp:ListItem></asp:ListItem>
                                <asp:ListItem Text="Select" Value="0" Selected="True" />
                                <asp:ListItem Text="A-group" Value="A-group" />
                                <asp:ListItem Text="B-group" Value="B-group" />

                            </asp:DropDownList>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lblDropDownListVaca" runat="server" Text='<%# Eval("namevacation") %>'></asp:Label>
                        </ItemTemplate>
                        <ControlStyle Width="100px" />
                        <ItemStyle HorizontalAlign="Center" Width="100px"></ItemStyle>
                    </asp:TemplateField>



    Saturday, January 16, 2021 1:41 AM
  • User-1545767719 posted

    Please answer to my question first. I repeat it below:

    What is the Viaible property you put in the Label control above?

    Saturday, January 16, 2021 2:10 AM
  • User-1683022223 posted

    no  Viaible property 

    Saturday, January 16, 2021 2:12 AM
  • User-1545767719 posted

    no  Viaible property 

    The above does not answer to my question. you say "no Viaible property". So what?

    If you have difficulty in English writing please ask somebody else to write your question. Otherwise we will not be able to communicate here. 

    Saturday, January 16, 2021 2:41 AM
  • User-1683022223 posted

    sir thanks for replay

    you mean Visible property >?

    yes its by namevacation if this A-Group or B-Group

    anyway i fix it now its working very well

     <asp:Label ID="lblBoxDate3" runat="server" Text='<%# Eval("vacationdata", "{0:yyyy/MM/dd}")%>'  Visible='<%# Eval("namevacation").ToString() == "A-group" ? true : false %>'></asp:Label>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, January 16, 2021 11:29 AM
  • User-943250815 posted

    You almost there, place both labels on same itemtemplate and make a small ajustment on Visible property

    <asp:TemplateField HeaderText="A/B-gorup">
      <ItemTemplate>
        <asp:Label ID="lblBoxDate3" runat="server" Text='<%# Eval("vacationdata","{0:ddd yyyy/MM/dd}") %>' Visible='<%# Eval("namevacation").ToString() == "A-group" ? true : false%>'></asp:Label>
        <asp:Label ID="lblBoxDate31" runat="server" Text='<%# Eval("dateorder","{0:ddd yyyy/MM/dd}") %>' Visible='<%# Eval("namevacation").ToString() == "B-group" ? true : false%>'></asp:Label>
      </ItemTemplate>
      <ItemStyle HorizontalAlign="Center"></ItemStyle>
    </asp:TemplateField>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, January 16, 2021 11:45 AM
  • User-1683022223 posted

    thanks sir , its working now

    Saturday, January 16, 2021 11:47 AM