dkim18
asked on
dropdownlist in gridview in edit mode?
Hi,
I have this dropdownlist in gridview in edit mode.
It is telling me that the selectedvalue is not one of value in the list.
In my database, I have the folliwing values, active, inactive, reject.
My template looks OK to me.
Do you think the value in the database has some blank spaces after the value?
How to trim the space before I can bind it?? <%# Bind("status") %> =>> <%# Trim(Bind("status") ) %> or something??
I have this dropdownlist in gridview in edit mode.
It is telling me that the selectedvalue is not one of value in the list.
In my database, I have the folliwing values, active, inactive, reject.
My template looks OK to me.
Do you think the value in the database has some blank spaces after the value?
How to trim the space before I can bind it?? <%# Bind("status") %> =>> <%# Trim(Bind("status") ) %> or something??
<asp:TemplateField HeaderText="TAType">
<EditItemTemplate>
<asp:DropDownList ID="ddTAType" runat="server" SelectedValue='<%# Bind("status") %>'
<asp:ListItem>active</asp:ListItem>
<asp:ListItem>inactive</asp:ListItem>
<asp:ListItem>reject</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblTAType" runat="server" Text='<%# Bind("status") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
That just means that there isn't an exact match between the 'Status' column in the datasource, and the list items.
ASKER
record I selected to edit has a value of active.
So I don't know if the database has extra space at the end of the value, active___.
How can I trim that??
So I don't know if the database has extra space at the end of the value, active___.
How can I trim that??
How are you adding items to the DropDownList? Are they statically, or dynamically added? Is there a post-back involved when you experience this problem?
ASKER
Sorry I forgot about the detail view.
Basically, I have a gridivew and when selected a record, you will get a detail view.
From the detail view, you click a edit link to get into the edit mode.
I am trying to add a dropdownlist in edit mode. This error message comes out when I try to get into the edit mode.
Basically, I have a gridivew and when selected a record, you will get a detail view.
From the detail view, you click a edit link to get into the edit mode.
I am trying to add a dropdownlist in edit mode. This error message comes out when I try to get into the edit mode.
Ok, my friend, that is a completely different story, and yet it doesn't answer my question. I'll repeat it--"How are the items added to the DropDownList?"
ASKER
Sorry.
I don't follow your quesiton, "How are the items added to the DropDownList?"
I am using the sqldatasource to bind the detailview.
So the dropdownlist's status will get the value from the sqldatasource.
Like here,
asp:DropDownList ID="ddTAType" runat="server" SelectedValue='<%# Bind("status") %>'
<asp:ListItem>active</asp: ListItem>
<asp:ListItem>inactive</as p:ListItem >
<asp:ListItem>reject</asp: ListItem>
</asp:DropDownList>
Sorry if I am not answering your question.
I don't follow your quesiton, "How are the items added to the DropDownList?"
I am using the sqldatasource to bind the detailview.
So the dropdownlist's status will get the value from the sqldatasource.
Like here,
asp:DropDownList ID="ddTAType" runat="server" SelectedValue='<%# Bind("status") %>'
<asp:ListItem>active</asp:
<asp:ListItem>inactive</as
<asp:ListItem>reject</asp:
</asp:DropDownList>
Sorry if I am not answering your question.
Are you saying that you are getting values from the same SqlDataSource that the other data elements are bound to?
ASKER
Yes.
The detailsview will bind the data from my sqldatasource and status label in the detailsview has 'active' value.
Now I want to edit this detailsView and when i click edit, i want to create a dropdownlist and this dropdownlist should bind the 'active' value since that's the value of it from the sqldatasource.
Isn't that what I did here?? I am getting confused now..hhhh.
asp:DropDownList ID="ddTAType" runat="server" SelectedValue='<%# Bind("status") %>'
<asp:ListItem>active</asp: ListItem>
<asp:ListItem>inactive</as p:ListItem >
<asp:ListItem>reject</asp: ListItem>
</asp:DropDownList>
The detailsview will bind the data from my sqldatasource and status label in the detailsview has 'active' value.
Now I want to edit this detailsView and when i click edit, i want to create a dropdownlist and this dropdownlist should bind the 'active' value since that's the value of it from the sqldatasource.
Isn't that what I did here?? I am getting confused now..hhhh.
asp:DropDownList ID="ddTAType" runat="server" SelectedValue='<%# Bind("status") %>'
<asp:ListItem>active</asp:
<asp:ListItem>inactive</as
<asp:ListItem>reject</asp:
</asp:DropDownList>
Since you have these:
<asp:ListItem>active</asp: ListItem>
<asp:ListItem>inactive</as p:ListItem >
<asp:ListItem>reject</asp: ListItem>
I am guessing that you went to the designer for the DropDownList, and manually added those items. And, you are binding the DropDownList to the same SqlDataSource to get the value.
This should work as advertised, so the only thing that I can think of, is that the values are not matching from the database. Maybe, it is "Active", "Inactive", and "Reject", and not "active", "inactive", and "reject".
<asp:ListItem>active</asp:
<asp:ListItem>inactive</as
<asp:ListItem>reject</asp:
I am guessing that you went to the designer for the DropDownList, and manually added those items. And, you are binding the DropDownList to the same SqlDataSource to get the value.
This should work as advertised, so the only thing that I can think of, is that the values are not matching from the database. Maybe, it is "Active", "Inactive", and "Reject", and not "active", "inactive", and "reject".
ASKER
They are not all lower case. So I don't know why it is saying the selectedvalue doesn't exit in the list of items.
ASKER
I meant to say they are all in lower case.
When run the web site, and that page is displayed in the browser, how is that section rendered (View Source in browser)?
ASKER
Exact error message is
DDL1 has a selectedvalue which is invalid because it does not exist in the list of items.
Parameter name: value.
DDL1 has a selectedvalue which is invalid because it does not exist in the list of items.
Parameter name: value.
ASKER
If you are talking about the edit page, it has the error messages instead.
No, I am talking about right-clicking on the page in the browser, and selecting 'View Source'.
ASKER
by the way,
without the selectedvalue property. it works fine.
But it always defaults to the active no matter what true value might be.
asp:DropDownList ID="ddTAType" runat="server" > <asp:ListItem>active</asp: ListItem>
<asp:ListItem>inactive</as p:ListItem >
<asp:ListItem>reject</asp: ListItem>
</asp:DropDownList>
without the selectedvalue property. it works fine.
But it always defaults to the active no matter what true value might be.
asp:DropDownList ID="ddTAType" runat="server" > <asp:ListItem>active</asp:
<asp:ListItem>inactive</as
<asp:ListItem>reject</asp:
</asp:DropDownList>
ASKER
I understand that.
Are you asking for the detailview page prior to clicking the edit or after??
If you are talking about the after, the source view has the error page source instead.
If you are asking for the before you click the edit, it looks file as you expect since it doesn't have the dropdownlist yet.
Are you asking for the detailview page prior to clicking the edit or after??
If you are talking about the after, the source view has the error page source instead.
If you are asking for the before you click the edit, it looks file as you expect since it doesn't have the dropdownlist yet.
After clicking the "Edit".
ASKER
I only see the error page. Nothing gets rendered except you get the error message.
You only the error page html codes.
Sorry if I am wasting too much time of yours.
It seems to be a simple control but I am not getting it correctly.
Again thanks for your time
You only the error page html codes.
Sorry if I am wasting too much time of yours.
It seems to be a simple control but I am not getting it correctly.
Again thanks for your time
You know what would help me understand your problem? Can you give me a small test .aspx page that highlights your error?
ASKER
Unforutnately I cannot copy my error page since I don't have internet access from that system.
But I found a similar page online.
'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.ArgumentOutOfRangeE xception: '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:
[ArgumentOutOfRangeExcepti on: 'DropDownList1' has a SelectedValue which
is invalid because it does not exist in the list of items.
Parameter name: value]
System.Web.UI.WebControls. ListContro l.PerformD ataB inding(IEnumerable
dataSource) +1777763
System.Web.UI.WebControls. ListContro l.OnDataBi ndin g(EventArgs e)
+104
System.Web.UI.WebControls. ListContro l.PerformS elec t() +31
System.Web.UI.WebControls. BaseDataBo undControl .Dat aBind() +70
System.Web.UI.Control.Data BindChildr en() +216
System.Web.UI.Control.Data Bind(Boole an raiseOnDataBinding) +216
System.Web.UI.Control.Data Bind() +12
System.Web.UI.Control.Data BindChildr en() +216
System.Web.UI.Control.Data Bind(Boole an raiseOnDataBinding) +216
System.Web.UI.Control.Data Bind() +12
System.Web.UI.WebControls. GridView.C reateRow(I nt32 rowIndex, Int32
dataSourceIndex, DataControlRowType rowType, DataControlRowState
rowState, Boolean dataBind, Object dataItem, DataControlField[] fields,
TableRowCollection rows, PagedDataSource pagedDataSource) +221
System.Web.UI.WebControls. GridView.C reateChild Cont rols(IEnumerable
dataSource, Boolean dataBinding) +3004
System.Web.UI.WebControls. CompositeD ataBoundCo ntro l.PerformDataBinding(IEnum erable
data) +59
System.Web.UI.WebControls. GridView.P erformData Bind ing(IEnumerable
data) +11
System.Web.UI.WebControls. DataBoundC ontrol.OnD ataS ourceViewSelectCallback(IE numerable
data) +111
System.Web.UI.DataSourceVi ew.Select( DataSource Sele ctArguments
arguments, DataSourceViewSelectCallba ck callback) +29
System.Web.UI.WebControls. DataBoundC ontrol.Per form Select() +149
System.Web.UI.WebControls. BaseDataBo undControl .Dat aBind() +70
System.Web.UI.WebControls. GridView.D ataBind() +4
System.Web.UI.WebControls. BaseDataBo undControl .Ens ureDataBound() +82
System.Web.UI.WebControls. CompositeD ataBoundCo ntro l.CreateChildControls()
+69
System.Web.UI.Control.Ensu reChildCon trols() +87
System.Web.UI.Control.PreR enderRecur siveIntern al() +41
System.Web.UI.Control.PreR enderRecur siveIntern al() +161
System.Web.UI.Control.PreR enderRecur siveIntern al() +161
System.Web.UI.Page.Process RequestMai n(Boolean
includeStagesBeforeAsyncPo int, Boolean includeStagesAfterAsyncPoi nt)
+1360
================
It is kind of strange. If I just put a lable and use the same <%# Bind('staut') %> it attaches the right value.
So I don't get it..
But I found a similar page online.
'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.ArgumentOutOfRangeE
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:
[ArgumentOutOfRangeExcepti
is invalid because it does not exist in the list of items.
Parameter name: value]
System.Web.UI.WebControls.
dataSource) +1777763
System.Web.UI.WebControls.
+104
System.Web.UI.WebControls.
System.Web.UI.WebControls.
System.Web.UI.Control.Data
System.Web.UI.Control.Data
System.Web.UI.Control.Data
System.Web.UI.Control.Data
System.Web.UI.Control.Data
System.Web.UI.Control.Data
System.Web.UI.WebControls.
dataSourceIndex, DataControlRowType rowType, DataControlRowState
rowState, Boolean dataBind, Object dataItem, DataControlField[] fields,
TableRowCollection rows, PagedDataSource pagedDataSource) +221
System.Web.UI.WebControls.
dataSource, Boolean dataBinding) +3004
System.Web.UI.WebControls.
data) +59
System.Web.UI.WebControls.
data) +11
System.Web.UI.WebControls.
data) +111
System.Web.UI.DataSourceVi
arguments, DataSourceViewSelectCallba
System.Web.UI.WebControls.
System.Web.UI.WebControls.
System.Web.UI.WebControls.
System.Web.UI.WebControls.
System.Web.UI.WebControls.
+69
System.Web.UI.Control.Ensu
System.Web.UI.Control.PreR
System.Web.UI.Control.PreR
System.Web.UI.Control.PreR
System.Web.UI.Page.Process
includeStagesBeforeAsyncPo
+1360
================
It is kind of strange. If I just put a lable and use the same <%# Bind('staut') %> it attaches the right value.
So I don't get it..
I haven't a clue as to why you are having that problem.
ASKER
This shouldn't be this diffcult. This is very common controls but I can't believe I can't find a solution.
I will have to do some behind the code operations to get this work.
I googled around found some people having similar issues but can't find clear solution to it.
Thanks for your time.
I will have to do some behind the code operations to get this work.
I googled around found some people having similar issues but can't find clear solution to it.
Thanks for your time.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks TheLearnedOne for your help.
I worked it out. You R right. I just didn't know how to use the dropdownlist's property in the detailsview.
I worked it out. You R right. I just didn't know how to use the dropdownlist's property in the detailsview.