Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8710691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:41:21+00:00 2026-06-13T04:41:21+00:00

Possible Duplicate: Conditional Logic in ASP.net page I am new to ASP.NET. Lets say

  • 0

Possible Duplicate:
Conditional Logic in ASP.net page

I am new to ASP.NET.

Lets say I have couple tables, and some tables I used TD tag to place the GridView and DetailsView in side. Note that these DetailsView and GridView are not related like one click another refresh, just display records. In DetailsView, I also have Add, Edit, and Delete Option. Example below.

<form name="form1" runat="server" class="FormDetail">
<table width="80%" align="center" >
    <tr>
        <td width="20%"></td>
        <td width="80%" class="PageTitle"></td>
        <td width="20%">
            <asp:Button runat="server" CommandName="AddNewProposal" ID="AddNewProposal" Text="Create Note" 
            href="ProposalCreateNote.aspx?ProposalID=ProposalID=" 
            title="Create Note" class="button3"/>           
        </td>
    </tr>
</table>   

    <div style="width:40%; margin-right: auto; margin-left: auto;">
        <asp:DetailsView AutoGenerateRows="False" DataKeyNames="ProposedID" DataSourceID="SqlDataSource2"
            HeaderText="Proposal Detail View" ID="DetailsView1" 
            runat="server" Width="100%" validateRequest="false" 
            CssClass="products"
            HeaderStyle-CssClass="header"
            FieldHeaderStyle-CssClass="fieldHeader"
            AlternatingRowStyle-CssClass="alternating"
            RowStyle
            CommandRowStyle-CssClass="command"
            PagerStyle-CssClass="pager"
            >

        <Fields>
            <asp:TemplateField HeaderText="ProposedID" SortExpression="Name" > 
                <ItemTemplate >
                    <asp:Label ID="ProposalID" runat="Server" style="text-align:left;" 
                     Text='<%# Eval("ProposedID")%>' />
                </ItemTemplate>
            </asp:TemplateField>

            <asp:BoundField DataField="MDFName" HeaderText="MDF Name" SortExpression="MDFName" />  

                <asp:TemplateField HeaderText="VendorName">
                    <ItemTemplate>
                        <asp:Label ID="lblVendorName" runat="Server" style="text-align:left;" Text='<%# Eval("VendorName")%>'/>
                    </ItemTemplate>
                    <InsertItemTemplate>
                        <asp:DropDownList id="insertVendorName" datasourceid="VendorSqlDataSource"
                            datatextfield="VendorName" DataValueField="VendorID" 
                            SelectedValue='<%# Bind("VendorID") %>'
                            OnSelectedIndexChanged="ddlVendor_SelectedIndexChanged" 
                            runat="server" AutoPostBack="true">
                            <asp:ListItem Text="Select" Value="-1"></asp:ListItem>  
                        </asp:DropDownList>

                        <asp:SqlDataSource ID="VendorSqlDataSource"  ConnectionString="<%$Connectionstrings:ConnectionString%>"
                            SelectCommand="SELECT VendorID, VendorName from MDF_Vendor"  runat="server">
                        </asp:SqlDataSource>
                    </InsertItemTemplate>

                    <EditItemTemplate>
                        <asp:DropDownList id="updateVendorName" datasourceid="VendorSqlDataSource"  AutoPostBack="true"
                        datatextfield="VendorName"  DataValueField="VendorID"  
                        SelectedValue='<%# Bind("VendorID") %>'     
                        runat="server" 
                        OnSelectedIndexChanged="ddlVendor_SelectedIndexChanged"  />                       
                        <asp:SqlDataSource ID="VendorSqlDataSource"  ConnectionString="<%$Connectionstrings:ConnectionString%>"
                            SelectCommand="SELECT VendorID, VendorName from MDF_Vendor"  runat="server">
                        </asp:SqlDataSource>
                    </EditItemTemplate>
                </asp:TemplateField>

        </Fields>

        </asp:DetailsView>                   
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ConnectionStrings:ConnectionString %>"
            SelectCommand="SELECT p.*
                        , (SELECT VendorName FROM MDF_Vendor WHERE VendorID = p.VendorID) AS VendorName
                        , (SELECT VendorBUName FROM MDF_VendorBU WHERE VendorBUID = p.VendorBUID) AS VendorBUName
                        FROM dbo.MDF_Proposed p Where p.ProposedID = @ProposedID"
            UpdateCommand="UPDATE [MDF_Proposed] SET [VendorID] = @VendorID
                        , [VendorBUID] = @VendorBUID
                        , [MDFSummary] = @MDFSummary
                        , [MDFAmount] = @MDFAmount
                        , [BeginDate] = @BeginDate
                        , [EndDate] = @EndDate
                        WHERE ProposedID = @ProposedID"
            InsertCommand = "INSERT INTO [MDF_Proposed] ([VendorID], [VendorBUID], [MDFName], [BeginDate], [EndDate], [CreatedBy]) 
                             VALUES (@VendorID, @VendorBUID, @MDFName, @BeginDate, @EndDate, '1234') "
            DeleteCommand = "DELETE  [MDF_Proposed]  WHERE ProposedID = @ProposedID"
        >   
            <SelectParameters>
                    <asp:QueryStringParameter Name="ProposedID" QueryStringField="ProposedID"  runat="server" />
            </SelectParameters>                        
            <UpdateParameters> 
            <asp:Parameter Name="ProposedID" Type="Int32" />
            </UpdateParameters>                    
        </asp:SqlDataSource>
    </div>

<hr align="center" width="96%" size="1" color="darkblue" /> 

<!-- //////////////////// NEED TO HIDE THI TABLE WHERE QueryString Mode=Insert ///////////////////// -->
<table  align="center"  width="96%" id="table2" border="0">
    <tr>
         <td class="center TitleSmall">Notes</td>
     </tr>
    <tr>
        <td width="48%">
    <asp:GridView ID="GridView_Note" runat="server"
    AutoGenerateColumns="False" 
        DataKeyNames="ProposedNoteID"
        DataSourceID="dsProposalNote" 


        ShowFooter="true"
        CssClass="mGrid"
        PagerStyle-CssClass="pgr"
        AlternatingRowStyle-CssClass="alt"                      
    >
    <AlternatingRowStyle ForeColor="Black"  BackColor="#F7F6F3"  VerticalAlign="top" />
    <HeaderStyle BackColor="#B5DAFF" Font-Bold="True" HorizontalAlign="center" />
    <PagerStyle BackColor="Gold" ForeColor="White" HorizontalAlign="Center" />    
    <FooterStyle Font-Bold="True" ForeColor="White"  BackColor="" />
        <Columns>

            <asp:BoundField DataField="ProposedNoteID" HeaderText="ID"  ItemStyle-Width="5%" />
            <asp:TemplateField ItemStyle-Width="70%">
                <ItemTemplate>

                    <asp:Label runat="server" DataField="Note" HeaderText="Note" Text='<%#Eval("Note") %>' />

                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="CreatedBy" HeaderText="Created By"  ItemStyle-Width="13%"/>
            <asp:BoundField DataField="CreatedDate" HeaderText="Created Date"  ItemStyle-Width="12%" DataFormatString="{0:dd/MM/yyyy}"/>

            <asp:TemplateField HeaderText="Delete"> 
                <ItemTemplate> 

                    <asp:LinkButton ID="btnDelete" runat="server" CommandName="Delete" Text="Delete" 

                  OnClientClick="return confirm('Are you certain you want to delete this?');"/> 

                </ItemTemplate> 
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
        <asp:sqldatasource ID="dsProposalNote" runat="server"  ConnectionString="<%$ConnectionStrings:ConnectionString %>"
        SelectCommand="Select * from MDF_ProposedNote where ProposedID = @ProposedID"    
        DeleteCommand="DELETE MDF_ProposedNote where ProposedNoteID = @ProposedNoteID"
            >
        <SelectParameters>
            <asp:QueryStringParameter Name="ProposedID" QueryStringField="ProposedID"  runat="server" />
        </SelectParameters>

    </asp:sqldatasource>

    </td>
        <td></td>
        <td width="48%"></td>
    </tr>
</table>
</form>

What I would like to do is that, if the QueryString is sending with insert mode on the URL (Page1.aspx?mode=insert). On page load, I want the DetailsView1 to be in the Insert mode, and hide the Table2, which contains the GridView (GridView_Note) and other HTMLcodes.

If this is classic ASP, I believe that I can store the queryString value in a variable and do and IF statement before the to display based on the condition of Page.asp?mode=insert.

Any suggestions how to accomplish this in ASP.NET? How can I store a variable and inject it inline with HTML codes? Please let me know if I confused you. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:41:22+00:00Added an answer on June 13, 2026 at 4:41 am

    You could wrap the table in an asp:placeholder or asp:panel and then in your Page_Load event query the QueryString collection for your “mode” key value pair and hide or show accordingly.

    HTML

    <asp:Panel id="pnlNotes" runat="server">
       ... Table and gridView
    </asp:Panel>
    

    Code Behind

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
             if (Request.QueryString["mode"] != null && Request.QueryString["mode"] == "Insert")
             {
                 pnlNotes.Visible = false;
             }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Type result with conditional operator in C# Basically I have some code
Possible Duplicate: Is there a conditional ternary operator in VB.NET? I have the folowing
Possible Duplicate: Ternary conditional operator in Python If I have some code like: x
Possible Duplicate: Conditional operator cannot cast implicitly? I have run into a peculiar situation
Possible Duplicate: Ternary conditional operator in Python I have this problem and have no
Possible Duplicate: XAML Conditional Compilation I am new to WPF. I just need to
Possible Duplicate: Conditional Linq Queries Using Entity Framework 4.0 I have a search condition
Possible Duplicate: Conditional “Browsable” Attribute I define AppSettings class that have a few properties.
Possible Duplicate: Is there a conditional ternary operator in VB.NET? Is there a version
Possible Duplicate: How to write conditional comment for non IE browsers? i have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.