473,588 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DropDown and ListBox

54 New Member
hi,
in vs2005, i have a control of gridview and dropdown. in dropdown list have a item of table header which i configured in gridview.
In Dropdown box, i selected one header means , it select the gridview particular column

here the code i try,
aspx
Expand|Select|Wrap|Line Numbers
  1. <body>
  2.     <form id="form1" runat="server">
  3.     <div>
  4.         <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID"
  5.             DataSourceID="SqlDataSource1" PageSize="5">
  6.             <Columns>
  7.                 <asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"
  8.                     ReadOnly="True" SortExpression="ProductID" />
  9.                 <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
  10.             </Columns>
  11.         </asp:GridView>
  12.         &nbsp;
  13.         <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
  14.             SelectCommand="SELECT * FROM [Current Product List]"></asp:SqlDataSource>
  15.  
  16.     </div>
  17.         <asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
  18.         </asp:DropDownList>
  19.         <asp:Label ID="Label1" runat="server"></asp:Label>
  20.     </form>
  21.  
  22. </body>
  23.  
c#
Expand|Select|Wrap|Line Numbers
  1. protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         foreach (TableCell header in GridView1.HeaderRow.Cells)
  4.         {
  5.             DropDownList1.Items.Add(header.Text);
  6.         }
  7.         label1.Text = DropDownList1.Items.Count.ToString();
  8.         a = DropDownList1.Items.Count.ToString();
  9.     }
  10.     protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  11.     {
  12.         int dd1=(GridView1.HeaderRow.FindControl("DropDowmList1"), DropDownList);
  13.  
  14.  
  15.  
  16.  
  17.         Label1.Text = DropDownList1.Items.Count.ToString();
  18.         Label1.Text = DropDownList1.SelectedIndex.ToString();
  19.  
  20.  
  21.         //DropDownList1.SelectedItem.Value=
  22.  
  23.  
  24.     }
  25.  
thanks,
murugavel
Jul 5 '08 #1
1 1663
Curtis Rutland
3,256 Recognized Expert Specialist
Was there a question in there? You made statements and posted code, but there wasn't really a question.

Also:

Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR
Jul 5 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
5246
by: J P Singh | last post by:
Hi There We have dropdown on ASP page. The problem is we have about 900 items in the dropdown. Users scrolling through the list have become very frustrated in the past. Can someone suggest if there is another way of implement a dropdown where the datalist is as big as ours. I am looking for something like a listbox in VB where you can start typing
4
3855
by: James W. Hall Sr. | last post by:
I am filling a dropdown listbox in ASP.NET. The display value is a date field from SQL Server. When I bind the data to the dropdown listbox the time appears in with the data (12:00 am). In the database it appear 12/31/2003. It appears in the control as 12/31/2003 12:00 am. I am trying to format the field in the select statement with no luck. Can anyone help me? James W. Hall Sr.
6
2704
by: A P | last post by:
Hi! I have seen some techniques like this on the web. Currently, I'm using Combo box which values came from database table. One disadvantage is when the combo box have lots of values, users are complaining since you cannot use keyboard to search the value that is needed. Hope you might help me. regards, Me
1
2128
by: seansan | last post by:
Hi, I ahve an issue that I could tackle myself. sometimes a dropdown box is filled with only one element. How can I set this dropdown box to auto-select this one option? So in VB. If my listcount of a dropdown element is 1 how do I capture the value of this element and set the dropdown box to show/select this one element? (instead of showing empty)
3
3055
by: Lloyd Sheen | last post by:
I have a page that works fine. I am trying to optimize the page by overriding some of the Information that is being saved in the hidden VIEWSTATE. If I make the properties of the dropdown False for ViewState and True for AutoPostBack, it does reload the page but does not call the SelectedIndexChanged event. If I put the ViewState to True then it is called. Does this mean that I cannot get that event and deal with it in better code
4
4581
by: Paul | last post by:
I have a dropdown list box and a button on a web form, the autopost back is false for the dropdown list box and button. When the button is pushed the selection in the dropdownlist box is lost, just wondering what is wrong. Selected value is always 1 no matter what is selected in the dropdown list box. Private Sub btn_yes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_yes.Click Dim s_origidval As String
1
25714
by: acord | last post by:
Hi, I am having problem to get a value of the selected item from a dropdown listbox. Here is the JS function; function getSelectedItem(objSelect) { alert("in getSelectedItem"); alert (objSelect.length); alert (objSelect.value);
7
5880
by: Peter | last post by:
Does anyone know of a good dropdown WebForm control that works like the Windows Forms dropdown control with type ahead feature, Where user can type in a value and it automatically displays the like values in the listbox, or user can click on the down arrow to bring a list of all items? I have found controls but they either do no let you type in the box or there is no down-arrow to click to display all of the items in the listbox, just...
1
1297
by: servernet1997 | last post by:
I have a gridview with 4 columns. Two of the columns are read-only and two are editable. The two editable columns are listboxes leveraging an ObjectDataSource. The first listbox is populated from a table of static information, the second listbox is more problematic. If the contents of the first listbox contains one specific value, I want to populate the second listbox with the results of QueryA when the row is edited. If the contents of...
6
5904
by: Amirtha | last post by:
hi frnds, I need ur help .im new to the javascript. i want to drag and drop an item from one dropdown listbox to an another dropdown listbox.i dont know how to do this. if possible means plz help me by giving ur suggestion
0
7927
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7857
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
7981
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6632
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3846
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2367
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1457
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1194
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.