Connecting Tech Pros Worldwide Forums | Help | Site Map

GridView w/ drop down menu

Slickuser
Guest
 
Posts: n/a
#1: Oct 7 '08
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?=
Guest
 
Posts: n/a
#2: Oct 7 '08

re: GridView w/ drop down menu



"Slickuser" wrote:
Quote:
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 DataGridViewComboBoxColumn?

http://msdn.microsoft.com/en-us/libr...boxcolumn.aspx

--
Happy Coding!
Morten Wennevik [C# MVP]
Slickuser
Guest
 
Posts: n/a
#3: Oct 7 '08

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.comwrote:
Quote:
"Slickuser" wrote:
Quote:
Hi,
>
Quote:
I would like to put a drop down menu in a gridview with the datatype
selected from the SQL database.
>
Quote:
These are the values will show.
red
orange
white
green
>
Quote:
It shows the selected on the drop down list.
>
Quote:
Currently, I'm query a SQL statement and put these in gridview using
datasource, datatable & sqladapter to show text.
>
Quote:
Any help for drop menu?
>
Would you be thinking of a DataGridViewComboBoxColumn?
>
http://msdn.microsoft.com/en-us/libr...forms.datagrid...
>
--
Happy Coding!
Morten Wennevik [C# MVP]
Slickuser
Guest
 
Posts: n/a
#4: Oct 7 '08

re: GridView w/ drop down menu


Here's the screen shot:
http://img510.imageshack.us/img510/2629/sn1uj0.jpg

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="Default.aspx.cs" Inherits="_Default" %>

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

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="colorDrop" runat="server"
OnSelectedIndexChanged="DropDownList1_SelectedInde xChanged">
<asp:ListItem>orange</asp:ListItem>
<asp:ListItem>red</asp:ListItem>
<asp:ListItem>blue</asp:ListItem>
<asp:ListItem>green</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="testLbl" runat="server"></asp:Label><br />
<br />
<br />
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:BoundField DataField="COLOR" HeaderText="Color" /
Quote:
>
<asp:CheckBoxField DataField="ENABLE"
HeaderText="Yes" />
<asp:ButtonField ButtonType="Button"
CommandName="DeleteMe" Text="Delete" />
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>



protected void DropDownList1_SelectedIndexChanged(object sender,
EventArgs e)
{
testLbl.Text = colorDrop.SelectedValue.ToString();
}



Closed Thread