473,387 Members | 1,517 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,387 software developers and data experts.

reorderlist - error when using with databound dropdownlist - unable to bind selectedv

Hi, this question relates to a control in the Ajax toolkit for asp.net 2. I'm having a problem using a databound dropdownlist inside a reorderlist ajax control. Here's a snippet of the code I'm using:

Expand|Select|Wrap|Line Numbers
  1. <InsertItemTemplate>
  2.     <div class="insertArea">
  3.     <asp:DropDownList ID="lstUser" runat="server" DataSourceID="UserDataSource" DataTextField="UserName" DataValueField="UserId" SelectedValue='<%# Bind("UserId") %>' AppendDataBoundItems="true"></asp:DropDownList>
  4.     <asp:TextBox ID="txtPhone" runat="server" MaxLength="20" Width="150" Text='<%# Bind("ContactPhone") %>'></asp:TextBox>
  5.     <asp:TextBox ID="txtEmail" runat="server" MaxLength="255" Width="400" Text='<%# Bind("ContactEmail") %>'></asp:TextBox>
  6.     <asp:Button ID="cmdAdd" runat="server" Text="Add" CommandName="insert" />
  7.     </div>
  8. </InsertItemTemplate>
When clicking the Add button, I get a "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control."

The bizarre thing about this is that the exact same code works fine in the EditItemTemplate. As far as I know, I need to bind the UserId so that it gets fed into the UserId parameter in the objectdatasource. If I remove the SelectedValue='<%# Bind("UserId") %>' part then I no longer get the error, but the objectdatasource tries to pass null for the userid to the database, which is of no use.

Here is the insert section of the objectdatasource for reference:

Expand|Select|Wrap|Line Numbers
  1. <InsertParameters>
  2.     <asp:ControlParameter Name="Company" ControlID="lstCompany" PropertyName="SelectedValue" Type="Int32" />
  3.     <asp:Parameter Name="UserId" Type="Object" />
  4.     <asp:Parameter Name="Sequence" Type="Int32" />
  5.     <asp:Parameter Name="ContactPhone" Type="String" />
  6.     <asp:Parameter Name="ContactEmail" Type="String" />
  7. </InsertParameters>
Hope to get some help on this as it's really bugging me.

Regards,
Mark
Apr 5 '07 #1
1 2587
kenobewan
4,871 Expert 4TB
Welcome to the site. What happens if you remove the div?
Apr 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Patrick.O.Ige | last post by:
Hi All, I have a code below:- That Binds a DropDownList to a database using ArrayList. This code works well in ASP.NET webMatrix. But when i use it below in VS.NEt it gives me the error:-...
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: Mark Micallef | last post by:
Hi, I'm having a problem using a databound dropdownlist inside a reorderlist ajax control. Here's a snippet of the code I'm using: <InsertItemTemplate> <div class="insertArea">...
0
daJunkCollector
by: daJunkCollector | last post by:
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" > </cc1:ToolkitScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> ...
4
by: jehugaleahsa | last post by:
Hello: I am going through an effort to standardize web applications for my company. We are trying to figure out the best practices for security, error handling, etc. I've just done a large...
1
by: bogdan | last post by:
I need to execute some code _after_ page controls are bound to data (e.g. DropDownList). I could probably handle DataBound events for each control. But if I wanted to place the code in a page...
6
by: Jonathan Wood | last post by:
I have a databound dropdownlist control. Based on some other criteria, I need to specify the selected item in my pages Load event. The problem is that, in my load event, the control does not yet...
6
by: Ahmedhussain | last post by:
Hi there, I m doing work on a gridview and Im getting an error: A potentially dangerous Request.Form value was detected from the client (ctl00$Content$GridView1$ctl03$TextBox1="<span...
3
by: semomaniz | last post by:
I have a ajax reorderlist that displays the contents with out any problems but when i drag and reorder the list nothing happens, i get a postback and the same initial list is displayed, seems like my...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.