Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dropdownlist in Datagrid with onselectchange event

Posted on 2004-09-22
5
Medium Priority
?
362 Views
Last Modified: 2008-02-01
Hi,
 I know this kind of question has been asked before but I couldnt find a concrete answer that closeley matched my problem.
Right now I have a Datagrid that looks like this
Name   Address    Phone    Edit   Delete   Generate No.
adf       adsfasd     12334   Edit   Delete    Generate No.

The last three columns are links to the repective pages with the CustomerID being passed through the links

I want to replace teh last 3 colums with 1 column that has a dropdownlist with Edit, Delete, Generate No. but keep the same functionality
The purpose is to save real estate on the page.

If someone has done something like this before and is willing to share the code, please help.

Thanks.
0
Comment
Question by:BrijBhasin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
praneetha earned 1000 total points
ID: 12128770
have a dropdownlist in a itemtemplate and bind it in itemdatabound

do this in itemdatabound

private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
            {
                  if(e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Footer)
                  {
                        System.Web.UI.WebControls.DropDownList ddl=(DropDownList)e.Item.FindControl("DropDownList1");
                        ListItem li=new ListItem("Add",e.Item.Cells[1].Text); //say e.item.cells[1].text - contains the id which u want to pass in the link
                        ListItem li1=new ListItem("Delete",e.Item.Cells[1].Text);
                        ddl.Items.Add(li);
                        ddl.Items.Add(li1);
                  }
            }

now set the autopostback=true and when index changed redirect to other page with selected value as parameter (values contain id)

or write a javascript onchange and access the value and then response.redirect

good luck

0
 

Author Comment

by:BrijBhasin
ID: 12144346
praneetha,
  would you know how I can do this in VB and not C#?
0
 
LVL 15

Expert Comment

by:praneetha
ID: 12144430
well it should be same...u have itemdatabound in vb.net too....

and may be if loop looks diff and all that...otherwise it should be all same...

sorry i don't know much vb.net...but i am prety sure..it almost looks the same...

you just have to change the syntax..i am sure...events of datagrid are all same
0
 

Author Comment

by:BrijBhasin
ID: 12332777
Sorry praneetha I missed assigning the points to this question earlier.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question