GridView w/ drop down menu

S

Slickuser

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?
 
M

Morten Wennevik [C# MVP]

Slickuser said:
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/library/system.windows.forms.datagridviewcomboboxcolumn.aspx
 
S

Slickuser

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.
 
S

Slickuser

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_SelectedIndexChanged">
<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: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();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top