Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 23rd, 2004, 08:04 PM
Registered User
 
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to process data binded to datagrid?

Datagrids are great but there seems to be a lack of manipulating data that is binded to the columns. Say I want to set the selectedindex of a dynamically populated dropdownlist in a datagrid:

*this is populating the dropdownlist with day from 1 - 31.
<EditItemTemplate>
<asp:DropDownList id="edit_finishdate_day" DataSource="<%# PopulateDay() %>" DataTextField="dayvalue" DataValueField="dayvalue" SelectedIndex='<%# DataBinder.Eval(Container.DataItem, "finishdate") %>' runat="Server"></asp:DropDownList>
</EditItemTemplate>

This won't work obviously because it pulls out the full date of 24/11/2004, when what I want is just the day: 24.

So how can I process the Container.DataItem or perform an expression on it to find just the day.


The setting of the selectedindex in the dropdownlist is just an example. Say I was pulling out the document size which is stored in the database as bytes eg. 55655

<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "documentsize") %>
</ItemTemplate>

and I wanted to display the size in Kb, or Mb.

Would appreciate any help.

Cheers.

 
Old December 1st, 2004, 05:16 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You can put additional logic inside of the binding syntax and you can put additional literal text outside the binding syntax in the template:

<ItemTemplate>
<%# CType(DataBinder.Eval(Container.DataItem, "documentsize"), Integer) / 1024 %> Kb
</ItemTemplate>





Similar Threads
Thread Thread Starter Forum Replies Last Post
process.startinfo opens new instance of process Anypond General .NET 0 August 28th, 2008 05:35 AM
Add Item in a Binded Combo Box prasanta2expert C# 2 April 21st, 2008 08:45 AM
Highlit the new data over the old data in DataGrid kotanaresh_2003 ASP.NET 1.0 and 1.1 Basics 0 April 12th, 2007 10:26 PM
Get Data from Datagrid rstelma ASP.NET 1.0 and 1.1 Professional 2 September 25th, 2006 11:28 PM
Adding an element to a binded DropDownlist mahulda ASP.NET 1.0 and 1.1 Basics 3 March 10th, 2004 03:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.