473,811 Members | 3,521 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_description s 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(ko unt))'
seems to overwrite the 'cell.Controls. Add(lbl_temp)', and I get left
with no Column header.

Ideas?

Cheers.
Jun 27 '08 #1
1 1767
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_description s 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(ko unt))'
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
12361
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 contains multiple panels within the form. The panels appear at different times - for our argument, let's say panel 1 appears first, users clicks a submit button and then panel 1 disappears and panel 2 appears, etc. When clicks on the submit button...
5
1590
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: _________________________________________________________________________________________________________ Imports System.ComponentModel Imports System.Web.UI Imports System.Web.UI.WebControls <Description("Provides a login component"), DefaultProperty(""),
3
1679
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 something like this: Owner: Rob Meade
4
2096
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. Each question is displayed and answered, then result written to a SQL table. Then the next question is read from a table and displayed using the load_page event again. The questions display and function perfectly. The user anwers the question...
15
2206
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) Dim dSet As DataSet Dim sqlConn As SqlConnection Dim sqlDapter As SqlDataAdapter sqlConn = New SqlConnection("Data Source=AD\SQLEXPRESS;Initial
3
1267
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 twice in a table. Both cells are identical and therefore I don't want to duplicate everything in the code. My function determines at runtime if there should be two identical cells or just a single cell. Here is some sample code, which only...
0
1811
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 per row of the table. I have easily constructed the table, but on the postback, I am unable to access the controls... Here is an example of the code: ''' <summary>Page Load</summary> ''' <remarks> ''' <para>Ensure that the querystring has a...
3
3105
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 postback - but if I press a submit button the textboxes keep the value. My problem is the following: I would like to use this Code to collect the data: 'Collects values - is calles from a button
0
1746
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 have no idea how to figure out whether anyone checked any of the boxes, though! I've tried to loop through the controls to see if any are checkboxes, but I can't seem to get "inside" the calendar itself. Any ideas or guidance would be appreciated....
0
9726
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10384
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9204
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7667
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6887
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4338
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.