472,374 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Adding Dropdownlist to GridView

My Time table has TimeID,Employee,PayPeriod,ChargeCodeID,Hours
My Chargecode table has ChargecodeID,c_Text

I need an Editable datagrid that will show the
TimeID,Employee,PayPeriod,C_Text in a label and hours, along with an
edit linkbutton.

When they click on edit, the edit button turns to Update Cancel

TimeID stays read Only
Employee stays read only
PayPeriod stays read only
C_Text turns into a dropdownlist so they can select the proper
chargecode via a dropdownlist
Hours is read/write

What is the best way to do this? I would have thought I add a gridview,
configure the datasource to the Time Table. Then, I go to the
ChargecodeID field and ask for it to be converted to a templatefield.

When i open the templatefield there is a label field in there. I delete
it. I add a dropdownlist. I set its datasource to a source linked to
the ChargeCode Table. I go to Choose datasource and select c_text as
the field to display, ChargeCodeID as the value for the dropdown.

Next I go to edit data bindings and for Selectedvalue I set field
binding to ChargeCodeID
When I try to open the page I get an error message

'DropDownList1' has a SelectedValue which is invalid because it does
not exist in the list of items.
Parameter name: value
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: 'DropDownList1'
has a SelectedValue which is invalid because it does not exist in the
list of items.
Parameter name: value

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentOutOfRangeException: 'DropDownList1' has a SelectedValue which
is invalid because it does not exist in the list of items.
Parameter name: value]
System.Web.UI.WebControls.ListControl.PerformDataB inding(IEnumerable
dataSource) +1777763
System.Web.UI.WebControls.ListControl.OnDataBindin g(EventArgs e)
+104
System.Web.UI.WebControls.ListControl.PerformSelec t() +31
System.Web.UI.WebControls.BaseDataBoundControl.Dat aBind() +70
System.Web.UI.Control.DataBindChildren() +216
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +216
System.Web.UI.Control.DataBind() +12
System.Web.UI.Control.DataBindChildren() +216
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +216
System.Web.UI.Control.DataBind() +12
System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32
dataSourceIndex, DataControlRowType rowType, DataControlRowState
rowState, Boolean dataBind, Object dataItem, DataControlField[] fields,
TableRowCollection rows, PagedDataSource pagedDataSource) +221
System.Web.UI.WebControls.GridView.CreateChildCont rols(IEnumerable
dataSource, Boolean dataBinding) +3004

System.Web.UI.WebControls.CompositeDataBoundContro l.PerformDataBinding(IEnumerable
data) +59
System.Web.UI.WebControls.GridView.PerformDataBind ing(IEnumerable
data) +11

System.Web.UI.WebControls.DataBoundControl.OnDataS ourceViewSelectCallback(IEnumerable
data) +111
System.Web.UI.DataSourceView.Select(DataSourceSele ctArguments
arguments, DataSourceViewSelectCallback callback) +29
System.Web.UI.WebControls.DataBoundControl.Perform Select() +149
System.Web.UI.WebControls.BaseDataBoundControl.Dat aBind() +70
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.Ens ureDataBound() +82

System.Web.UI.WebControls.CompositeDataBoundContro l.CreateChildControls()
+69
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +41
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+1360

Any help out there?

Nov 28 '06 #1
1 7683
Mitch,
I too am getting this same error.The odd thing is that I already have a
DropDown in different column, same grid, and its working. I'm trying to
add a 2nd Dropdown, but its not working. cannot figure out what the
error is.

Did you get your problem solved? If so can you share the solution?

Thanks,
rwiethorn
mi********@yahoo.com wrote:
My Time table has TimeID,Employee,PayPeriod,ChargeCodeID,Hours
My Chargecode table has ChargecodeID,c_Text

I need an Editable datagrid that will show the
TimeID,Employee,PayPeriod,C_Text in a label and hours, along with an
edit linkbutton.

When they click on edit, the edit button turns to Update Cancel

TimeID stays read Only
Employee stays read only
PayPeriod stays read only
C_Text turns into a dropdownlist so they can select the proper
chargecode via a dropdownlist
Hours is read/write

What is the best way to do this? I would have thought I add a gridview,
configure the datasource to the Time Table. Then, I go to the
ChargecodeID field and ask for it to be converted to a templatefield.

When i open the templatefield there is a label field in there. I delete
it. I add a dropdownlist. I set its datasource to a source linked to
the ChargeCode Table. I go to Choose datasource and select c_text as
the field to display, ChargeCodeID as the value for the dropdown.

Next I go to edit data bindings and for Selectedvalue I set field
binding to ChargeCodeID
When I try to open the page I get an error message

'DropDownList1' has a SelectedValue which is invalid because it does
not exist in the list of items.
Parameter name: value
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: 'DropDownList1'
has a SelectedValue which is invalid because it does not exist in the
list of items.
Parameter name: value

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentOutOfRangeException: 'DropDownList1' has a SelectedValue which
is invalid because it does not exist in the list of items.
Parameter name: value]
System.Web.UI.WebControls.ListControl.PerformDataB inding(IEnumerable
dataSource) +1777763
System.Web.UI.WebControls.ListControl.OnDataBindin g(EventArgs e)
+104
System.Web.UI.WebControls.ListControl.PerformSelec t() +31
System.Web.UI.WebControls.BaseDataBoundControl.Dat aBind() +70
System.Web.UI.Control.DataBindChildren() +216
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +216
System.Web.UI.Control.DataBind() +12
System.Web.UI.Control.DataBindChildren() +216
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +216
System.Web.UI.Control.DataBind() +12
System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32
dataSourceIndex, DataControlRowType rowType, DataControlRowState
rowState, Boolean dataBind, Object dataItem, DataControlField[] fields,
TableRowCollection rows, PagedDataSource pagedDataSource) +221
System.Web.UI.WebControls.GridView.CreateChildCont rols(IEnumerable
dataSource, Boolean dataBinding) +3004

System.Web.UI.WebControls.CompositeDataBoundContro l.PerformDataBinding(IEnumerable
data) +59
System.Web.UI.WebControls.GridView.PerformDataBind ing(IEnumerable
data) +11

System.Web.UI.WebControls.DataBoundControl.OnDataS ourceViewSelectCallback(IEnumerable
data) +111
System.Web.UI.DataSourceView.Select(DataSourceSele ctArguments
arguments, DataSourceViewSelectCallback callback) +29
System.Web.UI.WebControls.DataBoundControl.Perform Select() +149
System.Web.UI.WebControls.BaseDataBoundControl.Dat aBind() +70
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.Ens ureDataBound() +82

System.Web.UI.WebControls.CompositeDataBoundContro l.CreateChildControls()
+69
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +41
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+1360

Any help out there?
Dec 19 '06 #2

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

Similar topics

6
by: Dabbler | last post by:
I have a dropdownlist in a GridView ItemTemplate. I need to bind the ddl to an SqlDataSource, then have a value from a boundfield in the row be passed as the keyfield for select where clause. Im...
0
by: dawg1998 | last post by:
I am able to populate a DropDownList control within multiple rows of a GridView with the following code: `````````````````````````````````````````````````````` <asp:GridView id="gvGridView"...
0
by: Ben | last post by:
Hi, It's about a database containing (for simplifying) three fields: 'placenr' (primary key), 'place' and 'color'. The records are updatable (Edit/Update button) in a gridview. For updating the...
7
by: AG | last post by:
Hi, ASP.NET 2.0 web app I have a GridView utilizing template columns and bound to an objectdatasource. In the edit template of one column there is a dropdownlist bound to another...
0
by: sgtmarcjones | last post by:
How do I access a dropdownlist that is nested within a Formview ItemTemplate Gridview Template? I want to see a label (lgbTimeKeep ! TextValue of ddlName dropdownlist) instead of a dropdownlist...
3
by: Brian VanDyke | last post by:
I have to display a table with customer data (GridView). However, I want to be able to show DropDownList controls inside one of the columns, not just textbox controls. Is this possible? Is it...
0
by: lamolap | last post by:
i have 1 gridview , a dropdownlist inside a gridview and a commandfield of (edit, update and cancel) my gidview looks like this Edit Surname Initials ...
1
by: Anilsg | last post by:
Hi all, I have the DropDownList in the FormView,inside InsertTemplateField The data is binded in run time to it in codebehind page,FOr the First time the page is loaded the DropdownList is...
0
by: Fabrizio | last post by:
Hi all. I have a field in a gridview as templatefield which is a label in view mode and a dropdownlist in edit mode with his datasource. This gridview is inserted as templatefield in another...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.