Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 29th, 2004, 01:56 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

Please post it as a new topic to avoid confusion

Regards
Ganesh
 
Old December 1st, 2004, 05:27 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Originally posted by MrEdSolo


public void DataGrid1_DataBound(Object sender, DataGridItemEventArgs e)
        {
            if ((DataGrid1.EditItemIndex > -1)&&(e.Item.Cells[1].HasControls()))
            {
                Control myControl1 = e.Item.Cells[1].FindControl("ddlInspectors");
                if(myControl1!=null)
                {
                    DropDownList ddlInspectors = (DropDownList) e.Item.Cells[1].FindControl("ddlInspectors");
                    ddlInspectors.DataTextField = "ASPECTID";
                    ddlInspectors.DataValueField = "ASPECTID";
                    ddlInspectors.DataSource = ds.Tables[1].DefaultView;
                    ddlInspectors.DataBind();
                }
            }
        }
I changed your code,it's better to put your code in below if-statement for avoiding some probable errors,
Code:
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
            if (e.Item.ItemType == ListItemType.Item ||
                e.Item.ItemType == ListItemType.AlternatingItem ||
                e.Item.ItemType == ListItemType.SelectedItem ||
                e.Item.ItemType == ListItemType.EditItem)
            {    

                Control myControl1 = e.Item.FindControl("ddlInspectors");
                if(myControl1!=null)
                {
                    DropDownList ddlInspectors = (DropDownList) e.Item.FindControl("ddlInspectors");
                    ddlInspectors.DataTextField = "ASPECTID";
                    ddlInspectors.DataValueField = "ASPECTID";
                    ddlInspectors.DataSource = ds.Tables[1].DefaultView;
                    ddlInspectors.DataBind();
                }
            }

}
_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with dynamic drop down lists MarkGT Classic ASP Basics 3 April 29th, 2008 06:05 PM
Linked Drop Down Lists contagiouss_blue Excel VBA 6 June 8th, 2005 09:02 AM
Populating Drop Down based on other drop down jeffbarclay Java Databases 1 November 7th, 2003 12:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.