473,811 Members | 3,719 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 1674
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
5259
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
3869
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
2723
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
2142
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
3065
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
4595
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
25734
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
5888
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
1309
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
5941
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
9605
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,...
0
10651
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10405
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
9208
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...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6893
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5556
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...
2
3871
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.