findcontrol

GridView.Columns.Add vs GridView.Columns.Insert and GirdViewRow.FindControl

Hi guys I have noticed something that I find weird. Therefore I would like to get an explanation of how it works this way. I have a GridView, like this: <asp:GridView ID="_grdFordelinger" runat="server" CssClass="grid" AutoGenerateColumns="False"> <Columns> <asp:TemplateField> <HeaderTemplate> ...

Get DateTime Value from TextBox in FormView

I need to find a value in a TextBox, contained within a FormView which holds a short date. DateTime LastPayDate = (DateTime)FormView1.FindControl("user_last_payment_date"); I get the error: CS0030: Cannot convert type 'System.Web.UI.Control' to 'System.DateTime' And, I have no idea how to put a value back in the same format. Would ...

Retrieving keys and NewValues within a Formview with manual data binding

I have a Formview binded in the code file to a generic list. Now, upon editing of a record, I wish to access the Keys and NewValues out of the FormViewUpdateEventArgs parameter of the ItemUpdating event handler method. From what I've tried and searched over the internet as of now, I've come to know that updated values are only available...

Need help using C# FindControl

I have a repeater inside a panel. Inside this repeater I have another panel.Upon certain conditions, I want to set this panel.visibility = false. In the code behind, I try locating the panels on OnItemDataBound and set visible=false. But it only returns Object reference not set to an instance of an object.. I guesing it's because it ca...

Repeater control. Using a table that spans rows

The following "FindControl" method fails to find the imgAd control. Any idea why? Could it be the Table that contains it? The intent of the table is to line things up in columns across rows. <asp:Content ID="Content3" ContentPlaceHolderID="phPageContent" runat="Server"> <asp:Repeater ID="repBanner" runat="server"> <HeaderTem...

Unable to find control in asp.net Repeater control

This has got me stumped. I am trying to find a checkbox in a dynamically loaded asp.net Repeater template. The template works fine and the databinding is fine and everything displays fine but I can't find the control! Any ideas? This is the repeater code (I have a similar one for the alternate template with a different style): <%@ Cont...

Trouble with FindControl and dynamicly created controls

Example code: var div = new HtmlGenericControl("div"); div.Controls.Add(new Literal() { ID = "litSomeLit" }); var lit = (Literal)div.FindControl("litSomeLit"); Assert.IsNotNull(lit); This code fails the assert, because lit is null. Debugging shows that div.Controls definitely contains a literal with ID of "litSomeLit....

FindControl for nested controls in UserControl returns null

Hi everyone, I have a very weird issue. I have a UserControl that has some controls inside. I want to refer those controls after, in another postback. But when I try to get them the Controls property of my controls returns null. I'm working on vs2008. Here is the sample code: public partial class MyUserControl : System.Web.UI.UserCont...

why does findcontrol need unique id, when i have given it the row to scan.

the code public partial class Table_Traversing : System.Web.UI.Page { Table table1 = new Table(); Button button1 = new Button(); protected void Page_Load(object sender, EventArgs e) { for (int adding_rows = 0; adding_rows < 4; adding_rows++) { TableRow table_...

Set dropdownlist in gridview in rowediting event

Trying to get the findcontrol to work so I can set the default value of the dropdownlist I have in a template field, but I'm having no luck. Am I doing something wrong? Dim drdList As DropDownList For Each row As GridViewRow In gridviewComputer.Rows drdList = gridviewComputer.Rows(e.NewEditIndex).FindControl("statusDropDown...

Help to FindControl with dynamically created gridview using ITemplate

Good day all, I am having problems trying to use FindControl with my gridview. I am generating the gridview columns using the ITemplate function. This generates a bunch of textbox fields for me that the user has to input some data. The number of columns vary depending on user requirements, so I have to generate the grid dynamically. I...

ASP.NET How to access a deeply nested user control on the parent page

I have a login control and at is nested 2 deep in a header control i.e Page --> Header Control --> Login Control. I cannot get a reference to the control on the page using FindControl. I want to be able to set the visible property of the control like if (_loginControl != null) _loginControl.Visible = false; I ended up u...

finding control an a page with master page

Hi everyone, I have to find a Control(a Table) in an aspx page with master page : the Master page have this : <asp:ContentPlaceHolder ID="MainContent" runat="server"/> and int the child page : <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server"> </asp:Content> <asp:Content ID="Content2" Conte...

Using FindControl() to find control

I have a Literal control that I am trying to locate so I can insert text into it. I have a Master page that contains several content placeholders. <asp:Content ID="Content7" ContentPlaceHolderID="MainLinks" runat="server"> <h3>Project Navigation</h3> <ul class="rightColBoxNav"> <asp:Literal ID="litNavLinks" runat="server" /> </ul> ...

Changing MasterPage control text from ContentPage but still renders old text

Hey guys/girls I have a HyperLink in my MasterPage and i want to change the text of it from a ContentPage. This is how im doing it: In masterpage i included a public property: public string LinkExampleText { set { linkExample.Text = value; } } At the top of my content page, i added the following directive: <%@ MasterType V...

Find control in RoleGroup of LoginView

I have some textboxes and checkboxes inside a RoleGroup of a LoginView. How can I access these controls in my code-behind? <asp:LoginView ID="lgvAdmin" runat="server"> <RoleGroups> <asp:RoleGroup Roles="Administrator"> <ContentTemplate> <div class="floatL"> ...

_Setting_ textbox's text using FindControl

Hi all, I need to be able to set a textbox's (which is inside a gridview row) text to a certain string in runtime. I have used FindControl before, but can't figure out the syntax for actually setting the value of the textbox rather than just getting. Here's what I have, which doesn't compile: ((TextBox)e.Row.FindControl("txtPath")).Text...

Unable get Label.text in ASP.Net Repeater using FindControl

I can access the text within a textbox within my repeater, but I am unable to pull the text value from a label within my repeater. The repeater is populated from a datatable with row(x) being filled by sqlreader(x), I don't know if that makes a difference. I cannot use javascript for this. I need to access the label value from the codebe...

Find Control Asp.net

i have created <input type="checkbox" id="test" > using literal.. now i want to get this control so i can check if its checked or not.... how do i find this control in the aspx.cs page? ...

How to Findcontrol when we use literal to create it..

I am using a panel and then I create a literal in it, than I create : string temp =" <input type="checkbox" id="forum0"> <input type="checkbox" id="forum1"> <input type="checkbox" id="forum2"> <input type="checkbox" id="forum3"> <input type="checkbox" id="forum4"> <input type="checkbox" id="forum5"> " ... and then assign this sting t...