Web Forms :: Datalist Findcontrol Returns Null?
Mar 1, 2010
I have a datalist with price label
<asp:label runat="server" ID="lblPrice" Font-Bold="true" Font-Size="Medium"> <%# DataBinder.Eval(Container.DataItem, "dProduct_price") %></asp:label>
i have used to find the control in my code but when i debug the value is null
Label price = (Label)e.Item.FindControl("lblPrice");
View 1 Replies
Similar Messages:
Jul 6, 2010
Like the title says, when I try to get a control (HiddenField) using this.Parent.FindControl it returns an exception. Curiosly this only happens when I change the browser language to Italian, English but not Spanish (I'm from Argentina so everything in my computer is spanish).
View 3 Replies
Jan 31, 2010
Why method FindControl() returns null on FormView until call DataBind(). After that it returns everything correctly? What workaround are there? Call DataBind() before first call of FindControl() ?
View 3 Replies
Jan 7, 2010
I've been working for a long time with GridViews and DetailsViews, but yesterday I've come across a new scenario, which I quite do not understand.
I have a GridView with ImageButton (CommandName="Insert") which will change the mode of the DetailsView to Insert. Afterwards I'll look for a DropDownList inside that DetailsView and add some items dynamically. Works fine, but one first the first time I press that ImageButton. If I click on "Cancel" in the DetailsView and press the ImageButton again, the .FindControl() Method returns null.
I've created this sample: (To make it run in your Visual Studio, just bind a DataSource to the DetailsView, otherwise it will not be rendered)
Markup:
<asp:GridView ID="gvCategory" runat="server" OnRowCommand="gvCategory_RowCommand">
<Columns>
</Columns>
<EmptyDataTemplate>
[Code]....
I have also tried using a ItemTemplate, and not a InsertItemTemplate, but this results in the same. After using the ChangeMode-Method the DetailsView.CurrentMode == InsertMode. The only thing I can think of is, that the markup is already generated for the ItemTemplate and changing the Mode to InsertMode can't affect the rendered markup, or something like this.
View 1 Replies
Aug 31, 2010
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:
[code]....
View 2 Replies
Aug 20, 2010
I developed a page in VWD 2008 and it works perfectly locally, but when I deployed it on the server every Page.FindControl() call is causing the NullReference Exception "Object reference not set to an instance of an object. " Can anyone help me out? Code is below
[Code]....
View 1 Replies
Feb 9, 2010
[Code]....
now, I added information to the <headertemplate><table><tr><td>headers</td></tr></table></headertemplate>
and my label in the <itemtemplate><asp:Label id="Label1" runat="server"></asp:label></itemtemplate>
and now when I run my same code, I get [object reference not set to an instance of an object]
what gives? It was working until I added a header template.
View 2 Replies
Feb 17, 2011
I have a literal8 inside panel1 and panel1 inside datalist1 ..
i wanna insert the value in literal1 on page load event using query string ...
ERROR on Page Load : Object reference is not set to the instance of an object
how to make this code workin ?
Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
Dim lit8 As Literal = DirectCast(DataList1.FindControl("Literal8"), Literal)
lit8.Text = Me.Request.QueryString("room")
End Sub
View 1 Replies
Aug 24, 2010
I have a gridview. In the rowupdating event, the txtbox returns null. I have enabled viewstate for the gridview. But still it does not work. I have made this in Kentico.
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1" EnableModelValidation="True"
OnRowUpdating="GridView1_RowUpdating" >
<Columns>
<asp:CommandField ShowDeleteButton="True" CausesValidation="false" ShowEditButton="True"
ControlStyle-Width="100px" />
<asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderText="Name" SortExpression="name">
<ItemTemplate>
<asp:Label ID="lblRegionName" runat="Server" Text='<%# Bind("name") %>' Width="200px"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="EditRegionName" OnTextChanged="EditRegionName_Updated"
Text='<%# Bind("name") %>' Width="200px" />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox runat="server" ID="InsertRegionName" Text='' Width="200px" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderText="Archived" SortExpression="IsArchive">
<ItemTemplate>
<asp:CheckBox ID="lblArchive" Enabled="false" runat="Server" Checked='<%# DataBinder.Eval(Container.DataItem, "archived") %>'
Width="100px" />
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox runat="server" OnCheckedChanged="EditArchive_CheckedChanged" ID="EditArchive"
Width="100px" />
</EditItemTemplate>
<FooterTemplate>
<asp:CheckBox runat="server" ID="InsertArchive" Checked="false" Width="100px" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="btnHistory" runat="server" Text="History"></asp:LinkButton>
<ajaxToolkit:ModalPopupExtender OkControlID="OkButton" ID="ModalPopupExtender1" runat="server"
BackgroundCssClass="modalBackground" TargetControlID="btnHistory" PopupControlID="Panel1" />
<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Style="display: none">
<div>
<iframe frameborder="0" src="/CMSWebParts/MSM/RoundTableAfrica/Beheer/History.aspx?id=<%# DataBinder.Eval(Container.DataItem, "id") %>"
width="500px" height="100%" scrolling="no"></iframe>
<br />
<asp:Button ID="OkButton" runat="server" Text="OK" CausesValidation="false" Width="50" />
</asp:Panel>
</div>
</ItemTemplate>
<EditItemTemplate>
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="btnInsert" runat="server" Text="Insert" OnClick="Insert_Click" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
Region Name:<asp:TextBox runat="server" ID="NoDataRegionName" />
Archived:<asp:CheckBox runat="server" ID="NoDataIsArchive" />
<asp:Button runat="server" ID="NoDataInsert" CssClass="contentButton" Text="Insert"
OnClick="Button1_Click" />
</EmptyDataTemplate>
</asp:GridView>
<asp:Button runat="server" ID="Add" Text="Add" OnClick="Add_Click" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:RTAConnectionString%>"
ProviderName="System.Data.SqlClient" SelectCommand="select * from [spiderwebs_region] order by name "
UpdateCommand="UpdateRegionWithHistory" UpdateCommandType="StoredProcedure"
DeleteCommand="DeleteRegionWithHistory" DeleteCommandType="StoredProcedure" OnInserting="Sqldatasource1_Inserting"
OnInserted="Sqldatasource1_Inserted" InsertCommand="InsertRegionWithHistory"
InsertCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="id" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="action_time" Type="DateTime" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="content_type_id" Type="Int32" />
<asp:Parameter Name="object_repr" Type="String" />
<asp:Parameter Name="action_flag" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
Code Behind:
protected void Page_Load(object sender, EventArgs e)
{
GridView1.DataBind();
}
protected void GridView1_RowUpdating(Object sender, GridViewUpdateEventArgs e)
{
int index = e.RowIndex;
GridViewRow currentrow = ((GridView)sender).Rows[index];
TextBox txtbox = (TextBox)currentrow.FindControl("EditRegionName");
CheckBox isarchive = (CheckBox)currentrow.FindControl("EditArchive");
e.NewValues["name"] = txtbox.Text;
e.NewValues["archived"] = isarchive.Checked;
GridView1.EditIndex = -1;
GridView1.DataBind();
}
View 9 Replies
Oct 7, 2010
Since I am not using a DataSourceId at the markup I am having to create my own Sorting handler. I found a sample on MSDN but the variable 'dataTable' always returns null why?
[Code]....
and here is how I am feeding the DataGrid:
[Code]....
View 2 Replies
Mar 7, 2010
I've run into an issue where calling SiteMap.CurrentNode returns null when it really shouldn't be. I'm using SiteMap.CurrentNode to highlight certain buttons on the page and generate a sub navigation bar (through SiteMap.CurrentNode.ChildNodes).
Now this works until I attempt to get to my pages of which are generated by a dynamic provider. For some reason whenever I attempt this on my Projects page SiteMap.CurrentNode returns null. Overall this is a bad situation for my program because then I cant generate my sub-navigation bar.
I was hoping someone here might be able to figure out the fault in my Sitemap or provider so that I can do a basic tutorial to others who are attempting the same thing since I haven't seen a tutorial that implements a provider in the manner that I have.
Web.SiteMap:
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/Default.aspx" title="Home" description="Home page where updates and other information can be found">
<siteMapNode provider="ProjectProvider" />
<siteMapNode url="~/Contact/Default.aspx" title="Contacts" description="Contacts" />
</siteMapNode>.......
Provider:
Implements the following methods and all of them do not return Null (I checked via debug):
- RootNode
- GetRootNodeCore
- Initialize
- Clear
- BuildSiteMap
View 10 Replies
Dec 7, 2010
I have a treeView on my main page. While the page is postback the method TreeView.FindNode works fine. But when i return to main page from another, and loading ValuePath from session it returns null.
here is my treeView [Code]....
Code behind to save values in session on Page_Load:
[Code]....
Code behind to select TreeNode after return from other page on PageLoad
[Code]....
View 5 Replies
Mar 4, 2010
Our application uses the Enterprise Library's PropertyProxyValidator class to validate user input (v4.1 - Oct 2008). On occassion, the code will raise an exception saying the source type cannot be found. This error persists until the application pools recycle at night, at which point everything works again. It tends to only affect one of the web front ends at a time (there are two). I tracked down where the exception was being raised, and this is the section of code:
[Code]....
(As you can see, the value for this.SourceTypeName is shown in the exception and I've checked that it matches exactly.)
We have never been able to reproduce this exception and at this point don't have any ideas left as far as causes. For a while, my suspicion was that it was related to the Temporary ASP.NET Files folder. The last time the error occurred, I copied that folder from both web front ends. Then the next day when things were back to normal, I copied the folders. When I did a directory and file comparision of the affected web front end, I found no differences.
Our application is essentially user controls hosted in web parts on SharePoint (they don't do anything with SharePoint - in fact, for a while, we were developing the controls on ASPX pages). There are two servers in the farm, both with Windows Server 2003 R2 Standard x64, IIS 6, and .NET v3.5. This issue doesn't strike me as a problem with Enterprise Library or SharePoint, hence why I've posted here, but more so with assembly loading.
Any ideas for causes would be greatly appreciated. I could also use suggestions on tools I could use to try and debug this when happens again (it happens 2-3 times a month) in production.
View 11 Replies
Jan 19, 2010
I have a masterpage with three ContentPlaceHolder and a page derive from it.
Let's call the page derive from it as "PageFrom", the "PageFrom" has a GridView.
Each row in the GridView has a linkbutton which do a cross page postback to another page, "PageTo"
And I am trying to grab any control in the "PageFrom"
I have tried PreviousPage.FindControl() and PreviousPage.Master.FindControl(), none of them works.
The master page code
[Code]....
The PageFrom
[Code]....
The "PageTo" code-behind
[Code]....
View 2 Replies
Jul 20, 2010
I have a very strange issue where SelectionList always returns NULL when i try check its Selected Item/Value. I Googled a bit and I found out that when i click the submit button, the page is being refreshed and the SelectionList is being data bound again so it will revert back to its original behavior.
Then i tried enclosing the binding code in the Page_Load event in a !IsPostBack but still when i try to access the Selected property it is null and an exception is thrown.
My code goes something like this... (the braces are not matched properly)
static SelectionList[] Symptoms;
static string UserID = "";
cmbSymptoms1,cmbSymptoms2,cmbSymptoms3 and cmbSymptoms4 are SelectionLists. I took them in to an array of SelectionList and then set the properties.
I had to make them static or else when i click the button to update, they will not retain their values.
protected void Page_Load(object sender, EventArgs e)
{
if (this.IsPostBack == false)
{
//System.Diagnostics.Debug.WriteLine("Not IsPostBack");
if (Request.QueryString["id"] != null && Request.QueryString.ToString() != "")
{
//System.Diagnostics.Debug.WriteLine("id query string is not null :- " + Request.QueryString["id"]);
myclass = new Class1();...........
View 1 Replies
Nov 17, 2010
Im dynamically creating several dropdowns onclick of a button... but the dropdown returns null when im trying to get the values on submitting the form... i read tat during postback all dynamically created controls will be lost... s there a way to register the controls... i want to access the item selected in the dropdown .... expecting a positive reply...
View 1 Replies
May 22, 2010
I am working on a mvc project, and having problem with json. i have created a demo project with list of colors
public JsonResult GetResult()
{
List<string> strList = new List<string>();
strList.Add("white");
strList.Add("blue");
strList.Add("black");
strList.Add("red");
strList.Add("orange");
strList.Add("green");
return this.Json(strList);
}
i am able to get these on my page, but when i try to delete one color, that is when i send the following using jquery
function deleteItem(item) {
$.ajax({
type: "POST",
url: "/Home/Delete/white",
data: "{}",
contentType: "application/json; charset=utf-8",
success: ajaxCallSucceed,
dataType: "json",
failure: ajaxCallFailed
});
}
the controler action public JsonResult Delete(string Color) {} Color always returns null, even if i have specified "/Home/Delete/white" in the url. i know i am doing something wrong or missing something, but not able to find out what.
View 4 Replies
Feb 15, 2011
I have a class library which has my LINQ doc in it. I added a stored procedure and I get the following in my .dbml.layout :
[Code]....
I include a reference to the dll of the class library to my web project and I get an error about value being returned as int where I am trying to put contents into a datalist or similar.
Code in class that calls this SP :
[Code]....
So I switched code to the following in my dbml.layout document :
[Function(Name="dbo.sp_newsSearch")]public IEnumerable<news_search_result> sp_newsSearch([Parameter(DbType="VarChar(200)")] string searchVal){IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), searchVal);return ((IEnumerable<news_search_result>)(result.ReturnValue));}
And included the following in an external file news_search_result.cs
[Code]....
But now I just get nothing returned. Is this wrong way of calling a SP via LINQ? or have I just put the wrong return type on my LINQ class?
View 2 Replies
Feb 19, 2010
had used ajax.method in my project & its working fine, but now Every Ajax.Method returns null now,
View 1 Replies
Feb 13, 2010
I have a DataTable for which a PrimaryKey constraint has been set to be a combination of an integer column and a datetime column. When I try to 'Find' a row by saying,
dtFunds.Rows.Find(iContainerIndex)
I get a null value. iContainerIndex has been defined as an object array of size 2 with the integer ID and date values in it.
When I set a breakpoint in my code, I see that the very same values are present in the datatable.
If I try to execute, DataTable.Select() method with the integer column filter, I get a result - but returns no result when called with the date column filter.
What am I doing wrong here? The very same DateTime value is present in the datatable.
View 1 Replies
Nov 1, 2010
why the below javascript code always returns null (mean alert) ?
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication3.WebForm1" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<div>
<telerik:RadComboBox ID="RadComboBox1" runat="server">
</telerik:RadComboBox>
</div>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
var combo = $find("<%= RadComboBox1.ClientID %>");
alert(combo);
</script>
</telerik:RadCodeBlock>
</form>
</body>
</html>
View 2 Replies
Aug 17, 2010
I have a linq to sql entity class in which I declared some DateTime fileds like this:
[Code]....
And this is how I fetch data form repository:
[Code]....
All non DateTime fields are filled properly but all datetimes are null.[Column(DbType = "smalldatetime")]
View 8 Replies
Jul 30, 2010
I want to use multiple targets with my ModalPopUp extender. One of my buttons is set as target in the ModalPopup and the other one will use server-side code to show the ModalPopup.
This is my ModalPopup so far:
<msAjax:ModalPopupExtender ID="modalInform" runat="server"
BehaviorID="modalInform"
TargetControlID="btnSearchUsers" [code].....
Then I found this little tutorial on the ASP.NET AJAX site.But when I use $find("modalInform") in the pageLoad Javascript function (as defined in the tutorial at the bottom), I'm always getting a $find("modalInform") is null error.
This code is included in a usercontrol, the usercontrol is used in a ASPX page and this ASPX-page uses a MasterPage.
I've noticed that if I'm using
<%= modalInform.ClientID %>
I'm getting a different value then defined in my HTML-source (propably because of the MasterPage?).
View 1 Replies
Sep 2, 2010
It seemed to be the right place to post to.My problem is that when I try to read registry key, I get null value, even if it exists (regedit shows it exists).Application is windows service with Log On As Local System and registry key im trying to read is in HKEY_LOCAL_MACHINESOFTWAREClassesCLSIDOn my development machine (x64 win7) it works fine. But in live server (x64 windows server 2008 r2) I get NULL.ese operating systems should have similar policies or does Local System on server 2008 have any restrictions i should know about?
View 1 Replies
Oct 26, 2010
This is what I'm trying to run:
[Code]....
When I browse to www.mysite.com/mycontroller/myaction/myid, everything works ok. But visiting www.mysite.com/mycontroller/myaction produces:Server Error in '/' Application.Object reference not set to an instance of an object.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
View 3 Replies