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

controls.add overwrites cell text - boo!

I have a user control (called data_dictionary) which I need to add
into the header text of a datagrid. I'm doing this by adding the
control in the RowCreated event as follows:

dds_descriptions is an arraylist of strings. data_dictionary is the
user control

Expand|Select|Wrap|Line Numbers
  1. Sub gvw_data_RowCreated(ByVal sender As Object, ByVal e As
  2. GridViewRowEventArgs)
  3.  
  4. Dim kount As Integer
  5. Dim dds_item(e.Row.Cells.Count) As
  6. data_dictionary               ' user control
  7. Dim lbl_temp As New Label
  8.  
  9. If Not (e.Row Is Nothing) And e.Row.RowType =
  10. DataControlRowType.Header Then
  11. For Each cell As TableCell In e.Row.Cells
  12. If e.Row.Cells.GetCellIndex(cell) >=
  13. dds_descriptions.Count Then
  14. dds_descriptions.Add("")
  15. End If
  16. kount = e.Row.Cells.GetCellIndex(cell)
  17. dds_item(kount) = New data_dictionary
  18. dds_item(kount).data_description =
  19. dds_descriptions(kount)
  20. If cell.HasControls Then
  21. '  put a directional sort arrow on the header
  22. Dim button As LinkButton =
  23. DirectCast(cell.Controls(0), LinkButton)
  24. If Not (button Is Nothing) Then
  25. Dim image As Image = New Image
  26. If gvw_data.SortExpression <>
  27. button.CommandArgument Then
  28. image.ImageUrl = "http://b4/_style/
  29. noarrow.gif"
  30. Else
  31. If gvw_data.SortDirection =
  32. SortDirection.Ascending Then
  33. image.ImageUrl = "http://b4/_style/
  34. uparrow.gif"
  35. Else
  36. image.ImageUrl = "http://b4/_style/
  37. downarrow.gif"
  38. End If
  39. End If
  40. If dds_item(kount).data_description <"" Then
  41. cell.Controls.Add(dds_item(kount))
  42. cell.Controls.Add(image)
  43. End If
  44. End If
  45. Else
  46. If dds_item(kount).data_description <"" Then
  47. ' heres where the problem occurs
  48. lbl_temp.Text = cell.Text
  49. cell.Controls.Add(lbl_temp)
  50. cell.Controls.Add(dds_item(kount))
  51. End If
  52. End If
  53. Next
  54. End If
  55.  
  56. End Sub
  57.  
The problem I have, is that the 'cell.Controls.Add(dds_item(kount))'
seems to overwrite the 'cell.Controls.Add(lbl_temp)', and I get left
with no Column header.

Ideas?

Cheers.
Jun 27 '08 #1
1 1742
On 27 May, 16:23, DaveyP <davey.phill...@gmail.comwrote:
I have a user control (called data_dictionary) which I need to add
into the header text of a datagrid. I'm doing this by adding the
control in the RowCreated event as follows:

dds_descriptions is an arraylist of strings. data_dictionary is the
user control

Expand|Select|Wrap|Line Numbers
  1. * * Sub gvw_data_RowCreated(ByVal sender As Object, ByVal e As
  2. GridViewRowEventArgs)
  3. * * * * Dim kount As Integer
  4. * * * * Dim dds_item(e.Row.Cells.Count) As
  5. data_dictionary * * * * * * * ' user control
  6. * * * * Dim lbl_temp As New Label
  7. * * * * If Not (e.Row Is Nothing) And e.Row.RowType =
  8. DataControlRowType.Header Then
  9. * * * * * * For Each cell As TableCell In e.Row.Cells
  10. * * * * * * * * If e.Row.Cells.GetCellIndex(cell) >=
  11. dds_descriptions.Count Then
  12. * * * * * * * * * * dds_descriptions.Add("")
  13. * * * * * * * * End If
  14. * * * * * * * * kount = e.Row.Cells.GetCellIndex(cell)
  15. * * * * * * * * dds_item(kount) = New data_dictionary
  16. * * * * * * * * dds_item(kount).data_description =
  17. dds_descriptions(kount)
  18. * * * * * * * * If cell.HasControls Then
  19. * * * * * * * * * * ' *put a directional sort arrow on the header
  20. * * * * * * * * * * Dim button As LinkButton =
  21. DirectCast(cell.Controls(0), LinkButton)
  22. * * * * * * * * * * If Not (button Is Nothing) Then
  23. * * * * * * * * * * * * Dim image As Image = NewImage
  24. * * * * * * * * * * * * If gvw_data.SortExpression<>
  25. button.CommandArgument Then
  26. * * * * * * * * * * * * * * image.ImageUrl ="http://b4/_style/
  27. noarrow.gif"
  28. * * * * * * * * * * * * Else
  29. * * * * * * * * * * * * * * If gvw_data.SortDirection =
  30. SortDirection.Ascending Then
  31. * * * * * * * * * * * * * * * * image.ImageUrl = "http://b4/_style/
  32. uparrow.gif"
  33. * * * * * * * * * * * * * * Else
  34. * * * * * * * * * * * * * * * * image.ImageUrl = "http://b4/_style/
  35. downarrow.gif"
  36. * * * * * * * * * * * * * * End If
  37. * * * * * * * * * * * * End If
  38. * * * * * * * * * * * * If dds_item(kount).data_description <"" Then
  39. * * * * * * * * * * * * * * cell.Controls.Add(dds_item(kount))
  40. * * * * * * * * * * * * * * cell.Controls.Add(image)
  41. * * * * * * * * * * * * End If
  42. * * * * * * * * * * End If
  43. * * * * * * * * Else
  44. * * * * * * * * * * If dds_item(kount).data_description <"" Then
  45. * * * * *' heres where the problem occurs
  46. * * * * * * * * * * * * lbl_temp.Text = cell.Text
  47. * * * * * * * * * * * * cell.Controls.Add(lbl_temp)
  48. * * * * * * * * * * * * cell.Controls.Add(dds_item(kount))
  49. * * * * * * * * * * End If
  50. * * * * * * * * End If
  51. * * * * * * Next
  52. * * * * End If
  53. * * End Sub
  54.  

The problem I have, is that the 'cell.Controls.Add(dds_item(kount))'
seems to overwrite the 'cell.Controls.Add(lbl_temp)', and I get left
with no Column header.

Ideas?

Cheers.
bump.
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael | last post by:
Need some help trying to read values from web controls - specifically *finding* the controls (like a drop down list) - that are added dynamically added within an asp:panel control. The page...
5
by: Alex Nitulescu | last post by:
Hi. Because I'm a beginner in creating controls, I spent more than two *&^#$ hours to create this "login" as a custom control and to make it work properly: ...
3
by: Rob Meade | last post by:
Hi all, I would like to add more than one object to a table cell using the above, in this case some text and a hyperlink. I am writing the table row/cell programitcally and what to have...
4
by: Bass Pro | last post by:
Hi, I am creating textbox, radiobuttonlist and checkboxlist dynamically depending on data from a table. It is a questionnaire. I add the control on a Panel control during the 1st load_page event....
15
by: Arpan | last post by:
Consider the following code which retrieves data from a SQL Server 2005 DB table & displays it in a DataGrid: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)...
3
by: encoad | last post by:
Hi everybody, I'm hoping you can help me understand why this doesn't work, and perhaps someone can suggest a way for me to solve my problem. Essentially, I'm trying to add a row with a single cell...
0
by: comp974 | last post by:
ok, here is the situation, I am trying to construct a table with several ASP.net 2.0 controls in it during execution time in an VB.net enviroment. For starters, I have a textbox and a linkbutton...
3
by: Andreas Wöckl | last post by:
Hi Group! I have a web form that is created dynamically - so I create Textboxes, RadioButtonLists, CheckBoxLists and so on - I have found some articles that there may be some problems with...
0
by: creejohn | last post by:
Hi all-- I'm really stumped here. I have a (c# 2.0) calendar control that loads a menu for each day inside the cell corresponding to that day in the dayrender event. That is all working great. I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.