GridView w/ drop down menu

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Slickuser

    GridView w/ drop down menu

    Hi,

    I would like to put a drop down menu in a gridview with the datatype
    selected from the SQL database.

    These are the values will show.
    red
    orange
    white
    green

    It shows the selected on the drop down list.

    Currently, I'm query a SQL statement and put these in gridview using
    datasource, datatable & sqladapter to show text.

    Any help for drop menu?
  • =?Utf-8?B?TW9ydGVuIFdlbm5ldmlrIFtDIyBNVlBd?=

    #2
    RE: GridView w/ drop down menu


    "Slickuser" wrote:
    Hi,
    >
    I would like to put a drop down menu in a gridview with the datatype
    selected from the SQL database.
    >
    These are the values will show.
    red
    orange
    white
    green
    >
    It shows the selected on the drop down list.
    >
    Currently, I'm query a SQL statement and put these in gridview using
    datasource, datatable & sqladapter to show text.
    >
    Any help for drop menu?
    >
    Would you be thinking of a DataGridViewCom boBoxColumn?



    --
    Happy Coding!
    Morten Wennevik [C# MVP]

    Comment

    • Slickuser

      #3
      Re: GridView w/ drop down menu

      I'm using this for a web base form.

      I currently have the data but I am not sure if it can be achieve or
      not.

      On Oct 6, 10:54 pm, Morten Wennevik [C# MVP]
      <MortenWenne... @hotmail.comwro te:
      "Slickuser" wrote:
      Hi,
      >
      I would like to put a drop down menu in a gridview with the datatype
      selected from the SQL database.
      >
      These are the values will show.
      red
      orange
      white
      green
      >
      It shows the selected on the drop down list.
      >
      Currently, I'm query a SQL statement and put these in gridview using
      datasource, datatable & sqladapter to show text.
      >
      Any help for drop menu?
      >
      Would you be thinking of a DataGridViewCom boBoxColumn?
      >
      http://msdn.microsoft.com/en-us/libr...forms.datagrid...
      >
      --
      Happy Coding!
      Morten Wennevik [C# MVP]

      Comment

      • Slickuser

        #4
        Re: GridView w/ drop down menu

        Here's the screen shot:


        I can show ID & COLOR from SQL database as text.
        I just want to put these in a dropdownlist with value from SQL
        selected and other have generic one (not possible?)

        What I need put in my SQL to have the checkbox auto check or not
        check?

        Where can I enter my code to do what I want when the Delete button is
        press (mostly delete that row & delete from SQL). I named the command
        as DeleteMe.

        Also, my top drop down menu doesn't show my selected value to a label
        when change it.

        View source code below.. thanks a lot.

        <%@ Page Language="C#" AutoEventWireup ="true"
        CodeFile="Defau lt.aspx.cs" Inherits="_Defa ult" %>

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
        www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

        <html xmlns="http://www.w3.org/1999/xhtml" >
        <head runat="server">
        <title>Untitl ed Page</title>
        </head>
        <body>
        <form id="form1" runat="server">
        <div>
        <asp:DropDownLi st ID="colorDrop" runat="server"
        OnSelectedIndex Changed="DropDo wnList1_Selecte dIndexChanged">
        <asp:ListItem>o range</asp:ListItem>
        <asp:ListItem>r ed</asp:ListItem>
        <asp:ListItem>b lue</asp:ListItem>
        <asp:ListItem>g reen</asp:ListItem>
        </asp:DropDownLis t>
        <asp:Label ID="testLbl" runat="server"> </asp:Label><br />
        <br />
        <br />
        <asp:GridView ID="GridView1" runat="server"
        AutoGenerateCol umns="False">
        <Columns>
        <asp:BoundFie ld DataField="ID" HeaderText="ID" />
        <asp:BoundFie ld DataField="COLO R" HeaderText="Col or" /
        >
        <asp:CheckBoxFi eld DataField="ENAB LE"
        HeaderText="Yes " />
        <asp:ButtonFiel d ButtonType="But ton"
        CommandName="De leteMe" Text="Delete" />
        </Columns>
        </asp:GridView>
        </div>
        </form>
        </body>
        </html>



        protected void DropDownList1_S electedIndexCha nged(object sender,
        EventArgs e)
        {
        testLbl.Text = colorDrop.Selec tedValue.ToStri ng();
        }



        Comment

        Working...