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

  • Home
  • SEARCH
  • 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 7578837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:31:29+00:00 2026-05-30T17:31:29+00:00

I am developing a simple intranet suggestion box system that lets the employees being

  • 0

I am developing a simple intranet suggestion box system that lets the employees being able to submit their ideas through it. Now, for the System Admin, I list all the submitted suggestions with showing the employee name, username, division, suggestion title, suggestion description with adding one column that shows the status. For the Status column, it will show a DropDownList that contains the possible options such as Accepted, Rejected …etc

Here I have the following problem; when the admin selects one of status, it will be changed but after refreshing the page, the DropDownList will show the Select option again. What I want is to keep showing the Selected Value all the time instead of Select option.

My ASP.NET:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ID" 
                        width="950px" CssClass="mGrid"
                        AlternatingRowStyle-CssClass="alt" 
                        RowStyle-HorizontalAlign="Center" 
                        DataSourceID="SqlDataSource1" 
                        OnRowDataBound="GridView1_RowDataBound" >
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <HeaderStyle Font-Bold = "true" ForeColor="Black" Height="20px"/> 
            <Columns>
                <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
                    ReadOnly="True" SortExpression="ID" />
                <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                <asp:BoundField DataField="Description" HeaderText="Description" 
                    SortExpression="Description" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="Username" HeaderText="Username" 
                    SortExpression="Username" />
                <asp:BoundField DataField="DivisionShortcut" HeaderText="Division" 
                    SortExpression="DivisionShortcut" />
                <asp:TemplateField HeaderText="Status">
                    <ItemTemplate>
                        <asp:DropDownList ID="DropDownList" runat="server" DataSourceID="SqlDataSource2"
                                          Font-Bold="True" ForeColor="#006666" AppendDataBoundItems="false" 
                                          DataTextField="Status" DataValueField="ID" AutoPostBack="true" 
                                          OnDataBound="DropDownList_DataBound" OnSelectedIndexChanged ="DropDownList_SelectedIndexChanged">
                        </asp:DropDownList>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:testConnectionString %>" 
            SelectCommand="SELECT     dbo.SafetySuggestionsLog.ID, dbo.SafetySuggestionsLog.Title, dbo.SafetySuggestionsLog.Description, dbo.employee.Name, dbo.SafetySuggestionsLog.Username, 
                      dbo.Divisions.DivisionShortcut
FROM         dbo.employee INNER JOIN
                      dbo.SafetySuggestionsLog ON dbo.employee.Username = dbo.SafetySuggestionsLog.Username INNER JOIN
                      dbo.Divisions ON dbo.employee.DivisionCode = dbo.Divisions.SapCode"
                      FilterExpression="[DivisionShortcut] like '{0}%'">

                      <FilterParameters>
                        <asp:ControlParameter ControlID="ddlDivision" Name="DivisionShortcut" 
                                                 PropertyName="SelectedValue" Type="String" />
                    </FilterParameters>
        </asp:SqlDataSource>

        <%--For the DropDownList--%>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server"
                            ConnectionString="<%$ ConnectionStrings:testConnectionString %>" 
                            SelectCommand="SELECT * FROM [SafetySuggestionsStatus]">
        </asp:SqlDataSource>

UPDATE:

My Code-Behind:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[0].Text = i.ToString();
            i++;

            DataTable dt = new DataTable();
            DropDownList ddStatus = (DropDownList)e.Row.Cells[6].FindControl("DropDownList");
            ddStatus.DataTextField = "Status";
            ddStatus.DataValueField = "ID";
            ddStatus.DataSource = dt;//this datatable should be filled with all the possible values for the status
            ddStatus.DataBind();

        }
    }

    DataTable GetStatusTable()
    {
        SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM [SafetySuggestionsStatus]", "Data Source=localhost\\sqlexpress;Initial Catalog=psspdbTest;Integrated Security=True");
        DataTable dt = new DataTable();
        da.Fill(dt);
        return dt;
    }


    protected void DropDownList_DataBound(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ((DropDownList)sender).Items.Insert(0, new ListItem("--Select--", ""));
        }
    }

    protected void DropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList ddl = (DropDownList)sender;
        int suggestionStatus = int.Parse(ddl.SelectedValue);
        GridViewRow row = (GridViewRow)ddl.NamingContainer;
        string strID = GridView1.DataKeys[row.RowIndex]["ID"].ToString();
        int ID = Int32.Parse(strID);
        //For inserting the status in the database
        string connString = "Data Source=localhost\\sqlexpress;Initial Catalog=psspdbTest;Integrated Security=True";
        string updateCommand = "UPDATE SafetySuggestionsLog  SET [StatusID] = @StatusID WHERE [ID] = @ID";
        using (SqlConnection conn = new SqlConnection(connString))
        {
            conn.Open();
            using (SqlCommand cmd = new SqlCommand(updateCommand, conn))
            {
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@StatusID", suggestionStatus);
                cmd.Parameters.AddWithValue("@ID", ID);
                cmd.ExecuteNonQuery();
            }
            conn.Close();
        }

    }

**So how to fix this problem to let the status of the submitted suggestion be shown all the time?

  • 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-05-30T17:31:30+00:00Added an answer on May 30, 2026 at 5:31 pm

    try the below code for that field. The change is SelectedValue='<%# Bind(“StatusColumnName”) %>’

    <asp:TemplateField HeaderText="Status">
                        <ItemTemplate>
                            <asp:DropDownList ID="DropDownList" runat="server" 
                                              Font-Bold="True" ForeColor="#006666" AppendDataBoundItems="false" 
                                              AutoPostBack="true" 
                                              OnDataBound="DropDownList_DataBound" OnSelectedIndexChanged ="DropDownList_SelectedIndexChanged" SelectedValue='<%# Bind("StatusColumnName") %>'>
                            </asp:DropDownList>
                        </ItemTemplate>
                    </asp:TemplateField>
    

    Now add the below code

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow) //skip header row
        {
    DataTable dt= GetStatusTable();
            DropDownList ddStatus= (DropDownList)e.Row.Cells[5].FindControl("DropDownList");
            ddStatus.DataTextField="Status";
            ddStatus.DataValueField="ID" ;
    ddStatus.DataSource=dt;//this datatable should be filled with all the possible values for the status
    ddStatus.DataBind();
        }
    }
    
    DataTable GetStatusTable()
    {
     SqlDataAdapter da= new SqlDataAdapter("select Status,ID from Status","connectionstring here");
    DataTable dt= new DataTable();
    da.Fill(dt);
    return dt;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a simple ASP.NET website that will run on the intranet on
I'm developing a simple captcha system that uses jquery to refresh the image if
I am developing a simple software to check if I am able to program
I´m developing a simple form that allows users to check availability in a hotel
im developing a simple access application that helps us to order the right products
Im developing a simple application that have a line like this: string[] values =
I am developing a simple web apps that allowed user to key in information
I'm developing a simple protocol that is used to read/write integer values from/to a
I am currently developing a simple application in python that connects to a server.
I am developing an intranet web application. And I want to develop simple print

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.