Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / February 2004

Tip: Looking for answers? Try searching our database.

ItemDataBound event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Xu ChunMing - 21 Feb 2004 06:03 GMT
Hi All,
I see the following on MSDN:

The DataGrid control supports several events. One of them, the ItemCreated
event, gives you a way to customize the item-creation process. The
ItemDataBound event also gives you the ability to customize the DataGrid
items, but after the data is available for inspection. For example, if you
were using the DataGrid control to display a to-do list, you could display
overdue items in red text, completed items in black text, and other tasks in
green text.

I nearly want to do the same thing,
but in the event ,I can't access the value I wanted  with the commented
line, but this statemetn works well on the Item Updat event.

 public void MyDataGrid_DataBound(Object sender, DataGridItemEventArgs e)
 {
  //string s1
=((System.Web.UI.WebControls.TextBox)e.Item.Cells[7].FindControl("edit_Sate"
)).Text;
  if(s1=="UT")
  e.Item.BackColor =Color.Green ;
 }

I wonder how to access the one of the cell's bounded value of the just added
row.

Thanks!
Arvind P Rangan - 25 Feb 2004 11:58 GMT
Hi ChunMing,
Have you tried doing this in DAtaGrid_ItemCreate
under this
try in
if e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType =
ListItemType.Item
=((System.Web.UI.WebControls.TextBox)e.Item.Cells[7].FindControl("edit_Sate"
)).Text;
   if(s1=="UT")
   e.Item.BackColor =Color.Green ;
your code to change the color.

this option is for listing only not in edit mode.

Check it out.
Same syntax under this option.

> Hi All,
> I see the following on MSDN:
[quoted text clipped - 14 lines]
>   {
>    //string s1

=((System.Web.UI.WebControls.TextBox)e.Item.Cells[7].FindControl("edit_Sate"
> )).Text;
>    if(s1=="UT")
[quoted text clipped - 5 lines]
>
> Thanks!
Volkan Karabo?a - 26 Feb 2004 07:28 GMT
checkout the message which subject's is  "changing row color depending on a
cell value"
at this group sended 20/02/2004

I think it helps you...

> Hi All,
> I see the following on MSDN:
[quoted text clipped - 14 lines]
>   {
>    //string s1

=((System.Web.UI.WebControls.TextBox)e.Item.Cells[7].FindControl("edit_Sate"
> )).Text;
>    if(s1=="UT")
[quoted text clipped - 5 lines]
>
> Thanks!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.