Forms Data Controls :: Passing The Entire DataItem In A Databinding Expression?
Jun 16, 2010
Using an objectdatasource I would like to pass an entire DataItem to a function, within a databinding statement. I have found a way that works, but I don't like the look of it. ;-)
Lets say I have a class called "People", with two properties "firstName" and "lastName". I have an objectdatasource which returns a list of "People", and I use that to populate a Repeater.
I also have a function called "GetFullName", which takes a "People" object as it's parameter, and returns the lastname and firstname with a comma between them.
In the ItemTemplate of the repeater, I could do this:
<%# GetFullName(CType(Container, RepeaterItem).DataItem) %>
-but it looks like such a hack. (Doesn't it..? Maybe it's just me.)
View 3 Replies
Similar Messages:
Apr 26, 2010
input type=..... value="<%= ISO3166CountryList.GetCountryByCode("IE", CurrentLocale).Name %>" />
I'm looking to replace the hardcoded IE with something like
<%#(Container.DataItem as PhoneNumber).ISO%>
No variations of what I've tried worked. How can I get a databinded value when within a <%= code block? Do I need to use an intermediary variable?
View 2 Replies
Sep 16, 2010
I am collecting user roles into a single dimension string array.
I have a repeater that its source set to that array. The repeater template includes list of checkboxes for the values in the array.The checkbox text is set to: Text='<%# Container.DataItem %>'
All is good till this point.
But I am trying to call a javascript function triggered by clickign a checkbox and pass it the container.dataitem, but the javascript doesn't seem to be reading the value and either complain about string not being in correct format or that treats the container.dataitem as a liter. This is the trial that didn't work (I tried many different things too):
DetermineVal(<%# DataBinder.Eval(Container.DataItem) %>);
determineval is my javascript function
Can I do that with a single dimension array?
View 2 Replies
Oct 14, 2010
in aspx page
<cmp:MenuItemInfo Text="Delete" onclick="javascript:deleteRow('## DataItem.ClientId ##')" />
In Javascript
function deleteRow(rowId)
{
Projectgrid.deleteItem(Projectgrid.getItemFromClientId(rowId));
}
but the arument is coming as a string '## DataItem.ClientId ##' instead of correct clientID.
View 2 Replies
Mar 16, 2013
I m having a grid view on web3.aspx page
I am having another page web9.aspx page with a button on it.
On the click of this button i want to display the grid view present on web3.aspx.
View 1 Replies
Mar 23, 2013
i want to pass an entire grid view from once page to another without using web user control.
how can we create an instance of the grid view on some other page.
View 1 Replies
Sep 22, 2010
I'm trying to build a webpage without using any asp.net data binding controls ( listview, repeaters etc.)that I'm trying to do is to use stored procedure to get all necessary items, loop through them, and bind to labels, images etc.The problem is when i want to repeat .aspx code. I'm able to do everything i want in c#, but it's really pain to create all the necessary html elements such breaklines, spans, textboxes and so on.I tried to use expression builders, but it only repeats the last value from database.
Here is my code(ASPX):
[Code]....
c# code:
[Code]....
View 2 Replies
Nov 29, 2010
if i have a label control declared in page with text='<%# Eval("test") %>'
is it possible somehow to get this eval expression in codebehin for this label.
like string strBindExpression=... output should be test.
View 1 Replies
Mar 7, 2010
I'm just testing a simple databind expression with:
<div>
Now: <%# DateTime.Now.ToString()%>
</div>
According to MSDN:
[URL]
literal text <%# data-binding expression %>
should work.
When I compile, it's OK but I got a blank instead of Now DateTime.
View 1 Replies
Feb 22, 2010
I am working on a project where I have a form to create a new user. In that form we have a dropdown list that is populated from another table called ElectricCompanies. The Users table and ElectricCompanies tables are related (each User can only have one electric company, but electric companies can have multiple users). I am having trouble getting the Electric Company object to pass into the Users table. The Users table wants it to be passed as a object of the table ElectricCompanies, but right now it only passes the ID.
This is the code from the UserController under the Edit that I used to populate the ElectricCompany dropdown list:
Dim eleccomp = (From p
In _DB.ElectricCompanySet Select p)
ViewData("ElecComp") = New SelectList(eleccomp,
"ID", "Name")
Is there a way to pass an entire object rather than just the ID?
View 2 Replies
May 19, 2010
I have the following HTML with a databinding expression as shown below:
[Code]....
The 'title' tag's expression gets evaluated fine.
But not the one in 'href' attrib of the 'link' tag. The HTML source generated shows the literal text "..this.BaseURL.../..."
Any idea what could be happening?
View 3 Replies
Sep 23, 2010
I've bound a IeNumerable<class> to a repeater.On the repeater i've got a ItemDataBound.Right there i want the value of 1 of the items in my string s.So i've build this code.But if i run it i get this error:
System.Web.HttpException: DataBinding: 'dftv.AutoDiskClass+Merk' does not contain a property with the name 'nMerkID'.
if i run it again and put a breakpoint at this row, and push the DataItem, i get this information.
But how can i get the value of nMerkID in my string?The class i put in it is:
public class Merk
{
public string nMerkID = "";
public string Merknaam = "";
}
View 10 Replies
Mar 2, 2010
I'm trying to populate the DataPager using Container.DataItem (I'm not allowed to use FindControl) but I get this error
'System.Web.UI.WebControls.DataPager' does not contain a definition for 'DataItem' and no extension method 'DataItem' accepting a first argument of type 'System.Web.UI.WebControls.DataPager' could be found (are you missing a using directive or an assembly reference?)
The code:
[Code]....
View 4 Replies
Dec 21, 2010
I want to acces Container Dataitem in <%.
Is it possible to do that?
I want to pass the current dataitem to a method and check if it's valid then show a button.
This <% %> is located inside a repeater.
<%
if (Validate( (Order)Container.DataItem))
{ %>
<asp:button text=edit>
<% }%>
View 4 Replies
Jul 2, 2010
I have a problem that is really confusing me.. I'm trying get get info from a database and populate the relevant labels. I've got it working on one page, but not on another. The only difference is that the one that works is in a repeater.
My code is as follows:
[Code]....
The error I am getting is the following:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. review the following specific error details and modify your source code
appropriately.
Compiler Error Message: CS0117: 'System.Web.UI.Page'does not contain a definition for 'DataItem'
Source Error:
[Code]....
View 3 Replies
Mar 3, 2010
I am NOT formatting at DECLARATIVE time
The following code works perfectly
[Code]....
Can I directly format e.RowDataItem.
I don't want to format by using e.Row.Cells[4].Text
View 3 Replies
Jan 23, 2011
How to deal with Null values in GridView Container.DataItem
[Code]....
View 1 Replies
Mar 29, 2010
I tried translating this from vb but getting the error on e.Row.DataItem("CustomerID").ToString i tried varios things but no gooddbSrc.SelectCommand = "SELECT * FROM Orders WHERE CustomerID = '" + e.Row.DataItem("CustomerID").ToString + "' ORDER BY OrderDate";
View 3 Replies
Feb 21, 2010
I was going to display some data using the datagrid tool but rather than being able to edit one row at a time I need to have all cells on all rows in the edit position and then I can save the entire table. Is this possible using datagrid and if not what how should I use a different control?
View 1 Replies
Feb 4, 2010
I am trying to use GridView in my asp.net page. My requirement is to select an entire row by clicking at any place(field) in the row. Is it possible to accomplish this without using Links or buttons for the fields..? I have searched the net but couldnt find any answer. Is it the GridView designed not to allow selection of a row..?
View 2 Replies
Dec 17, 2010
I am developing a project using Visual Web Developer 2008 express. I am displaying the excel data set into Grid view, each execl sheet having 400 records, i want save this whole grid view data into mysql table with single clickToacheive above task shall i need to create a table in mysql database having same excel names.
View 12 Replies
Mar 24, 2010
I am using a bound gridview in ASP.NET 2.0. The gridview has the ability to edit/update and insert rows. One of the columns holds a number which represents a percentage. What I cannot figure out is how to ensure that all the rows in the gridview total 100% before being able to send the updates or newly inserted data to the database.
For example say there are 5 rows in the gridview, each row has 20% stored in the column so it adds up to 100% which is fine, the data is updated/inserted in the database. But say each row only had 15% totalling 75%, the user should not be able to send the updated/inserted data to the database until either they add a new row with a percentage of 25 or they edit the other rows for a cumulative total of 100%
I am not familiar with javascript or AJAX
View 6 Replies
Oct 12, 2010
I have a datalist in my page that has a LinkButton at the beginning of each row that, when clicked, fires the Itemcommand ("select"). There is no issue with this as it works as it should:
[Code]....
But I also thought it would be good if the user could simply click anywhere in the datalist to expand the item and show based on the SelectedItemTemplate. So, I thought, the cleanest would be to add a function in the code behind that adds a click event to the Panel "panItem" that clicks the above mentioned LinkButton like this (fires in Page_PreRender):
[Code]....
Here is where the problem comes in. This works great in IE but not FF3.6 (havent tested it with older version of FF). In FF, I get a JS error saying "dlMapDB_ctl00_btnItemFigNumber is not defined" for the first row, "...ctl01..." for the second row, etc. So the IDs are correct based on the markup (which makes sense since it works in IE).
View 2 Replies
Feb 19, 2010
how can i disable an entire column of a gridview?
View 6 Replies
Feb 14, 2011
Is it possible to make a gridview so that when it is opened all the records are updatable without having to click on the Edit button? I assume you would have to use the EditItem property and possibly loop through the rows but I'm a newbie and don't know the code.
View 1 Replies