473,394 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Using DrowDownlist in GridView

Hi im trying to use DrowDownList in the Gridview control for the first
time and have just a little idea about how it works
i have tried some code from the net but was able to find the code of
DataGrid with DropDownList. But displays some error when i click on the
edit button
Im trying to use Dropdownlist in the gridview. but in the RowEditing
event The error is thrown here
protected void GridView1_RowEditing(object sender,
GridViewEditEventArgs e)
{
Response.Write("Value changed to ");

System.Web.UI.WebControls.Label lb = new
System.Web.UI.WebControls.Label();
DropDownList ddl = (DropDownList)
GridView1.SelectedRow.FindControl("ddl_UnitCode");
(Error is thrown here : Object reference not set to an instance of an
object.)
BindGrid();
}
the error occurs when i click on edit buttton..

Jan 13 '07 #1
2 1671
Im trying to use Dropdownlist in the gridview. but in the RowEditing
event The error is thrown here
System.Web.UI.WebControls.Label lb = new
System.Web.UI.WebControls.Label();
DropDownList ddl = (DropDownList)
GridView1.SelectedRow.FindControl("ddl_UnitCode");
(Error is thrown here : Object reference not set to an instance of an
object.)

No row is selected.
You are in edit mode... work with EditIndex.

DropDownList ddl = (DropDownList)
GridView1.Rows[e.NewEditIndex].FindControl("dll_UnitCode");

where e is GridViewEditEventArgs (parameter to the handler).
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujinionline.com
-----------------------------------------
Jan 14 '07 #2
Im trying to use Dropdownlist in the gridview. but in the RowEditing
event The error is thrown here
System.Web.UI.WebControls.Label lb = new
System.Web.UI.WebControls.Label();
DropDownList ddl = (DropDownList)
GridView1.SelectedRow.FindControl("ddl_UnitCode");
(Error is thrown here : Object reference not set to an instance of an
object.)

No row is selected.
You are in edit mode... work with EditIndex.

DropDownList ddl = (DropDownList)
GridView1.Rows[e.NewEditIndex].FindControl("dll_UnitCode");

where e is GridViewEditEventArgs (parameter to the handler).
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujinionline.com
-----------------------------------------
Jan 14 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
1
by: Edward | last post by:
On mine ASP 2.0 page I've two gridviews. The second depends on the selected value of the first one. Everything is working ok. When selecting a row from the first, the second gridview is displaying...
0
by: Sam | last post by:
I am fairly new to ASP. Net 2.0, background MS Access 2000/2003 and working knowledge of SQL 2000. Scenario: Page1: Blank Page loads with 2 Text Boxes (TxtLast, TxtFirst), a Command...
1
by: jmdolinger | last post by:
Hi all, I'm a newbie to Atlas (and recently ASP.NET) after coming from a long Java background, also have done quite a bit with an Ajax.NET/ASP.NET 1.1 project, but it was basically all...
4
by: Wannabe | last post by:
I am using ASP.Net 2.0 and have a gridview on my page. I have everything working except the delete command. The page reloads except the row I am trying to delete is still there. I believe it is...
1
by: Barry L. Camp | last post by:
Hi all, Wondering if someone can help with a nagging problem I am having using a GridView and an ObjectDataSource. I have a simple situation where I am trying to delete a row from a table, but...
7
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
Is there a way to use a gridview in a timecard application, and if so, how? I was looking at using a gridview to display a person's hours worked in a week. To do this, many different data records...
2
by: DC | last post by:
Hi, I am using a GridView to present data in a DataTable, which I store only in ViewState and when the user hits the "OK" button the rows in the DataTable will be used to execute transactions. ...
1
by: neobonzi | last post by:
Hello! I'm dynamically creating a GridView bound to a datatable using custom template columns using the following method: protected void ShowGrid(DataTable dt) { ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.