findcontrol

How to get all the controls inside a specific cell in a GridView

本秂侑毒 提交于 2021-01-28 00:16:07
问题 I am generating CheckBox controls dynamically inside a GridView. Now i need to validate if atleast one CheckBox is selected and also while saving data i need to iterate through all the controls inside the cell. Now the issue is i cannot do grdApproverDetails.Rows[i].FindControl('controlID') , because the ID's are dynamically generated based on the control count. As shown in this thread. This is how the GridView looks and Approver Name is the column inside which i need to find controls, if

FindControl Returning Null

纵饮孤独 提交于 2020-05-11 07:09:11
问题 I am trying to contol a buttons state depending on a relevant text box. The names are the same other than the prefixes. The text boxes and buttons are located in a table on the page. <asp:Table ID="Table1" runat="server" CssClass="table"> <asp:TableRow> <asp:TableCell Width="15%"> <asp:Label ID="lblRequestHeader" runat="server" Text="Requested" CssClass="bold text-center" Width="90%"></asp:Label> </asp:TableCell> <asp:TableCell Width="15%"> <asp:Label ID="lblApprovalHeader" runat="server"

FindControl Returning Null

可紊 提交于 2020-05-11 07:08:04
问题 I am trying to contol a buttons state depending on a relevant text box. The names are the same other than the prefixes. The text boxes and buttons are located in a table on the page. <asp:Table ID="Table1" runat="server" CssClass="table"> <asp:TableRow> <asp:TableCell Width="15%"> <asp:Label ID="lblRequestHeader" runat="server" Text="Requested" CssClass="bold text-center" Width="90%"></asp:Label> </asp:TableCell> <asp:TableCell Width="15%"> <asp:Label ID="lblApprovalHeader" runat="server"

FindControl Returning Null

我怕爱的太早我们不能终老 提交于 2020-05-11 07:07:53
问题 I am trying to contol a buttons state depending on a relevant text box. The names are the same other than the prefixes. The text boxes and buttons are located in a table on the page. <asp:Table ID="Table1" runat="server" CssClass="table"> <asp:TableRow> <asp:TableCell Width="15%"> <asp:Label ID="lblRequestHeader" runat="server" Text="Requested" CssClass="bold text-center" Width="90%"></asp:Label> </asp:TableCell> <asp:TableCell Width="15%"> <asp:Label ID="lblApprovalHeader" runat="server"

ListView FindControl error

拜拜、爱过 提交于 2020-02-07 07:25:47
问题 I have the next error: System.NullReferenceException – Object reference not set to an instance of an object. To the next code: <asp:ListView ID="LV1" runat="server" DataSourceID="LinqDataSource"> <ItemTemplate> <asp:Image ID="Image1" Width="100px" Height="100px" runat="server" ImageUrl='<%# Eval("ImageUrl") %>' /> //....and so on till the </asp:ListView> The code - behind: protected void checkTheImage() { ((Image)LV1.FindControl("Image1")).ImageUrl = "(noImage.jpg)" ; } and the code on page

c# - error using FindControl on div id

落爺英雄遲暮 提交于 2020-01-01 05:12:05
问题 I have an ASP.NET site that I am trying to access div elements by their ID from the C# code behind file. Essentially I want to see if a div element exists, and if so, alter its properties. I've found many resources out there that point to a dozen different solutions and none of them seem to work. HTML on ASP.Net Page: <div class="contentArea"> <div class="block" id="button1" runat="server"> Some Content Here </div> <div class="block" id="button2" runat="server"> Some Content Here </div> <div

Dynamically generated FileUploads can't give options

杀马特。学长 韩版系。学妹 提交于 2019-12-25 02:50:24
问题 I'm adding at my ASPX page some controls dynamically. I need to add dynamically them, because the amount of controls depends on database record. I'm using UpdatePanel and adding controls dynamically like that: void AddFileUploadFields() { for (int i = 0; i < Helper.uploadFieldsCount; i++) { FileUpload fileUpload = new FileUpload(); string controlId = DateTime.Now.Ticks.ToString(); Thread.Sleep(10); // for non-equal ID for each control fileUpload.ID = controlId; uploadFormsId.Add(controlId);

FindControl returns null in MasterPage

隐身守侯 提交于 2019-12-24 18:44:35
问题 I have a nested DataList in MasterPage. I'm trying to Findcontrol, but it returns null for DataList2. What I tried so far : DataList DataList1 = Page.Master.FindControl("DataListMain") as DataList; DataList DataList2 = DataList1.FindControl("DataListNested") as DataList; How can I fix this? 回答1: DataList has items. So you need to locate the nested DataList by index. DataList dl = ((DataList)Master.FindControl("DataListMain")).Items[i].FindControl("DataListNested") as DataList; Note however

gridview findcontrol returning empty “”

廉价感情. 提交于 2019-12-24 01:47:23
问题 i am trying to read from a textbox within a gridview by using this code protected void Button1_Click(object sender, EventArgs e) { foreach (GridViewRow row in GridView1.Rows) { string textBoxText = ((TextBox)row.FindControl("numTC")).Text; Response.Write(textBoxText); } } this code keeps returning "" (empty) any idea why this is hapenning? Thanks 回答1: Make sure that you are not re-binding the GridView on the PostBack of the page. This may be the issue. EDITS Make sure that the code for

FindControl looks for controls in incorrect template of FormView

有些话、适合烂在心里 提交于 2019-12-23 19:30:26
问题 How do you locate controls from the codebehind when switching modes in a FormView? It looks like you can't use FindControl during the Page_Load event, since it will be searching for controls in the previously shown template rather than the newly selected one. I suspect you can't rely on the PageLoad alone but have to find controls within another event, like OnDataBound, but should you really HAVE to do that? I've seen several formviews in my day that lack events like OnDataBound... More