Accessing web controls from within a DataGrid control

Hi, 

Could someone tell me how to access other web controls from within a datagrid control? I have a ListBox control in a DataGrid, but can't figure out how to set the ListBox's datasource from the code behind.
Any help would be great appreciated. Thanks.
0
leovish
3/18/2004 1:56:25 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
656 Views

Similar Articles

[PageSpeed] 14

With the DataGrid you have the ItemDataBound event, where you can find any web control that were added to it, for each row listed in the DataGrid.

Ex:

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim l As ListBox = e.Item.FindControl("ListBox1")
End If
End Sub

obs: ListBox1 is the ListBox's id that is inside the DataGrid.
0
julianobosco
3/18/2004 7:35:53 PM
Reply:

Similar Artilces:

User Control Within UserControl
If I have a user control A and then inside it a user control B embedded/referenced within it.  User Control A has a panel defined (cpeNewUser) that I want to manipulate from the code behind of User Control B based on some event that happens.So putting this in my code behind of User Control B won't work as it has no idea of cpeNewUser:cpeNewUser.Collapsed = true;So is it because only at runtime they are married up and because of this you cannot access each other's objects at compile time?  How would I get this to work becuase I'm using all user controls inside a AJAX Too...

access controls on web user control x from web user control Y
I have 2 web users controls in a page and I would like to get or set the selected values of a few dropdown boxes on web user control X from web user control Y and I also would like to know how to access functions that are on a web user control X from a web user control Y, is this possible? How can I do it? User can access and set the values of the User Control from .aspx page through properties,using javascript and in code-behind of aspx page.The details of it are shown below Using PropertiesIf the Sample.ascx control has two textboxes and submit button.You can access the valu...

Custom Control within a Control Control
I am developing a custom controls that will render headers for different web sites. Within these controls, I want to place another custom control that will change the language. I created the language control and had it implement IPostBackDataHandler. This control works fine if I drag it on a new web form, but if I tell a header custom control to render it problems occur. The Language Selector custom control does not have a Page member anymore and the event handlers do not work. Does anyone have any experience with doing something similiar? Anyone have any suggestions? Thanks, ...

Accessing Web Controls within a User Control
Hi, I've built a page which contains a user control. The contents of this user control is a dynamically-built series of radiobuttonlists. What I need to be able to do is access these radiobuttonlists from the code behind the outer page, the one containing the user control. However, it seems as though I cannot do this. Looping through control.controls I can see a placeholder control within my user control, but not the dynamically generated radiobuttonlists beneath it. As far as I'm aware you can usually access dyanamically generalted controls by using control.controls, but this seems di...

Accessing controls within controls...
I am trying to write a sub that clears all textboxes on my page when it is called. I started with: Public Sub ClearForm()      Dim ctl As Control      For Each ctl In Page.Controls(1).Controls            Response.Write(ctl.ID)            If TypeOf ctl Is TextBox Then               CType(ctl, TextBox).Text = ""           ...

Access a controle within a controle
HelloI have a Datalist binded with a ObjectDataSource, wich then loads troughout a Class that uses storedprocedures.Now I want to customize a part of the DataList, I dropped a Label into the Datalist. Is there any simple way of accessing this label in the partial class of the aspx file? You'd normally call the parent control's FindControl() method. So, if your DataList had an ID of "DataList1" and your Label had an ID of "Label1" you do something like:Label lbl = (Label)DataList1.FindControl("Label1");lbl.Text = ...

controlling an object in a web control from the page the web control is placed in
I have created a web control in vb.net that has an image button and an image. when it loads the image button is visible and the image is not. I want to be able from the page which "includes" the web control to set the image button to invisible and the image to visible. When I tried this, the main page didn't recognise the image button or the image (both < asp: objects). help would be gratefully appreciated. oh yeah, it's inline code so any code behind stuff will just confuse me ;) Some code please.-- Justin Lovell...

How to access individual controls from a form containing the web user control containing those controls
 Below is a block of code in my .aspx form named default.aspx. In this form I load a web user control. I then add it to a place holder control.(Lines 3 and 4 below) So how do I access the individual controls in my web user control? I want to set the properties on those controls, but I am baffled as to how to access the control. For example I have a text label control named "label3". How do I access this control. Because for example, under certain situations I want to hide that control. ( Label3.Visible = false;)  1    if(!Page.IsPostBack) 2&nb...

Web control in web control
Hi,There are two simple web user controls A and B, where B contains A. They just display the bunch of text boxes, so I do not need them even in tool pane. They sit in the same project next to web form.I noticed that web user control put on ASPX page does not appear in code behind, but if I create it with protected keyword and name being exactly the same as id it works fine. I can access such a web control from code behind and see the value assigned in IE. The problem is that the same routine does work for my A web control in B. When I assign the value IE, I keep getting null reference. ...

How do you access controls within a web user control from another page?
Hi guys/girls. Say for instance you have a web user control with 2 textboxes in it - txtBoxFirstname and txtBoxSurname. I place this web user control on a page. How do I access those controls from that page? Thanks guys this.Findcontrol("UserControlName"); Hi,You can make two properties on the user control that will expose the Text property of the textboxes and then from the page you'll be able to use them.For example in the user control:public string Text1{   get   {       return Textbox1.Text;   }   s...

UpdatePanel within a web user control resets data of controls outside the user control
Hello, I have a usercontrol on my page which displays a running marquee text. It makes use of an UpdatePanel (within the user control) to refresh the marquee text (within the updatepanel) at periodic intervals. For this I added a timer control and its tick event as an async postback trigger for the UpdatePanel. I have a lot of textboxes and dropdown list boxes (all with runat=server) on the page outside the above user control. These are also contained in different UpdatePanels. Problem is, when the user control does a postback to refresh the marquee text, it causes some of...

Web Custom Control within a Web Custom Control
I was wondering if this can be done and how. I've created a simple custom control that displays a header which is my first custom control. So I'm just a baby when it comes to this.. Within the header I currently have a property for breadcrumbs which is a string. What I would like to do is have the breadcrumb property  be a Link Button List. I did find a custom control of a Link Button List which is exactly what I wanted. My question is how can/do  I include this into my custom control? Can it done? How? Please help? I'm at a lose here.   Susan You should be able to do ...

accessing a control on a different web controls
I have 2 web controls on one aspx page.  I want to set the label1.text property on control1 from a button click event on control2.  Is there any to do that?     Thanks Hi,the strategy is to let the Page take care of this flow. To do this, first expose the Label's text with a property declared in Control1, for example<% Control Language="C#" %><script runat="server">public string Text {    get { return myLabel.Text; }    set { myLabel.Text = value; }}</script><asp:Label id="myLabel" runat="server"></asp:Label>...

How to access controls within LoginView-Control?
.... <asp:LoginView ID="LoginView1" Runat="server"> <LoggedInTemplate> <font color="#ffffff">Logged in as:&nbsp; <asp:LoginName ID="LoginName1" Runat="server" ForeColor="White" /> </font> </LoggedInTemplate> ...

Web resources about - Accessing web controls from within a DataGrid control - asp.net.presentation-controls

Highest Percentage Of Opera Mini Users Accessing Facebook? Macau
If you were asked to guess which country had the highest percentage of users of Opera mobile Web browser Opera Mini users accessing Facebook ...

International Users Accessing Facebook Places Through US VPN Accounts
By using a virtual private network (VPN) hosted in the United States, Facebook users from around the world are accessing Facebook Places. The ...

What are some alternatives to Yodlee for accessing bank information?
Clay Loveless , Founder, Jexy. Co-founder, Mashery. Founder, Jexy. Co-founder, Mashery.

Cloud Console - Accessing files in cloud storage for iPad on the iTunes App Store
Get Cloud Console - Accessing files in cloud storage on the App Store. See screenshots and ratings, and read customer reviews.

Meryl Streep On Accessing The Characters Within - YouTube
Meryl Streep talks about the importance of an actors work representing their ability. CONNECT WITH AFI: http://facebook.com/AmericanFilmInstitute ...

Student pleads guilty to accessing records about Frances Abbott design scholarship
The Sydney student who leaked information about a fashion school scholarship controversially awarded to the daughter of the Prime Minister has ...

Accessing a headline opinion
Accessing a headline opinion

Sharp increase in authorities accessing private data
Australian law enforcement and government agencies have sharply increased their access without warrant to vast quantities of private telephone ...

Former librarian charged with accessing student records of Frances Abbott
A former part-time librarian at a Sydney design school has been charged after she allegedly accessed student records of Prime Minister Tony Abbott's ...

Frances Abbott scholarship: Sydney woman pleads guilty to accessing Whitehouse Institute records on PM's ...
A Sydney woman who leaked the student records of Tony Abbott's daughter pleads guilty. A Sydney woman who leaked the student records of Prime ...

Resources last updated: 1/16/2016 2:59:11 PM