Web Forms :: Add Variable Number Of Some Control?
Apr 7, 2010
I have a project with a database. There is a table in the database which store news. The news are composed by a headline and a link to a web page where you can read the news.
I want to make a unordered list, where, for each element in a database table, there will be a line in the list, with the news headline displayed by a Label control followed by a Hyperlink control that takes you to the news webpage.
How can I construct a page with a variable number of controls?
I was doing something like this:
<% foreach(News news in NewsTable) { %>
<asp:Label ...></Label>
<asp:HyperLink ...></HyperLink>
<% } %>
But the result of this is that I have the same Label and HyperLink drawed several times.
View 2 Replies
Similar Messages:
Feb 2, 2011
I'm a newbie here. I have created a custom control that requests a set of data from a user. However, I want to be able to have a variable number (dictated by the user) of these data sets entered on each page. How can I create and refer to a variable number of instances of a user control on a single page? It's hard to explain in words, but I'm basically looking for some way to do what amounts to the following:
[code].....
Is there a straightforward way of doing this? I haven't been able to find a clear answer via Google, which brought me to this group.
View 2 Replies
Dec 2, 2010
What would be the proper syntax in ASP.NEt 3.5 C# to assign a TextBox value to a temporary or session variable to be manipulated (added, subtracted, multiplied, divided) at different points in the application? I want to add a decimal number to this variable in almost every instance as well.
View 3 Replies
Aug 21, 2010
I need to provide some alternate content for my non-Flash users. I have a directory of video files that is scanned using the DirectoryInfo() function, and I want to use the results to embed all files ending in ".mov" in QuickTime players on a web form. How would you approach this? Right now I am using the count on the array of videos to determine how many times to repeat the embed code. But this seems inelegant.
Is there a way to have a single QuickTime player.ascx control that gets duplicated according to the number of videos available for display?
View 1 Replies
Oct 20, 2010
Nested GridView Control returns "Object variable or With block variable not set" when outer GridView returns rows.
The Nested GridView Control works as long as the outer GridView returns rows, the following code works: [Code]....
Object variable or With block variable not set.
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 variable or With block variable not set.
Source Error:
Line 118: If e.Row.RowType = DataControlRowType.DataRow Then
Line 119: Dim myStatus_ID As SqlDataSource = CType(e.Row.FindControl("sqlDeviceStatusAssign"), SqlDataSource)
Line 120: If Not e.Row.DataItem("Status_ID") Is Nothing Then
Line 121: myStatus_ID.SelectParameters(0).DefaultValue = e.Row.DataItem("Status_ID")
Line 122: End If
I have tried checking for IsDbNull and checking to see if a label exists in a given row. This code *If Not e.Row.DataItem("Status_ID") Is Nothing Then* appears to do nothing.Same with the following:
*Dim localLblItemReference As Label = CType(e.Row.FindControl("lblItemReference"), Label)
*If Not localLblItemReference Is Nothing Then
******************************************************************************************
To further clarify my question above, I am looking for a method to detect e.Row.DataItem("Status_ID") is nothing/null due to the outer GridView returning 0 results in a query.I have a (Outer) GridView Control with another GridView Control inside of a template field with it's associated SqlDataSource control.
In the "Protected Sub GridViewReport_RowCreated", I provide the Select Parameter for the associated SqlDataSource with the DataItem row value.When the (Outer) GridView Control does not return any rows, the "e.Row.DataItem("Status_ID")" throws a:
Exception Details: System.NullReferenceException: Object variable or With block variable not set.
View 3 Replies
Mar 18, 2011
I need to run a variable amount of insert statements. Is it best to run through a loop and execute the query one at a time? Or, is there a way to send all the inserts in one go?
View 5 Replies
May 17, 2010
I am working on a form which displays information about orders. Each order has a unique id, but they are not necessarily sequential on the form. Also, the number of fields can vary (one field per row on the form). The input into the form will not be mapped straight into the database, but will be added to the current value in the database, and then saved. An example of the form is in the picture below - the callout on the right shows the id for each row.
I know how to generate the form like this, but I can't work out how I can easily process each of these rows reliably. I also know how to give each of the fields a unique identifier, like name="order-23" or name="order[23]", but how can I translate that name so that I can update the related record in the database?
View 3 Replies
Dec 1, 2010
I wanted to gather some methods on how to add a variable number of fields to my form (with Add New and Remove buttons). I know that ASP.NET MVC has easy methods, but I'm unable to find any easy methods for WebForms.
Here's what I've used so far:
Adding a new UserControl to a PlaceHolder on PostBack (I've had to fiddle with ViewState to make this work correctly, huge pain) Adding a new row to a grid and having a template field in a grid (works decently but kind of awkward) Actually having several fields on the form by default and hiding/showing them dynamically (fairly easy but you have a set number of fields.)
View 1 Replies
Mar 7, 2011
I should perform a Query like this Select * from produtcts where model like @MODEL Now if model is selected from combobox, it should be Select * from produtcts where model like '%MODEL1%' while, if selected chooise is null, it should be like each element in my combobox. how should i do this (in SqlDataSource)
View 5 Replies
Feb 2, 2010
I am using the asp.net and framework 2.0 with Ajax enable web.i have a text box and when user will enter "a" or number in this will search the name started from "a" character or number if he or she enter the number basically we can say live-search.
Employee search: Textbox.In this text box she/he will enter the first character of name or first number of employeeno and according to the a character name will search in list.
View 1 Replies
Mar 25, 2011
Here upon loading the page there will be 4 panels having their own timer controls (having interval 1000) for incrementing a variable "a". But the problem is that, as I have used static variable that's why all the timer's are sharing the variable "a" and creating a problem like each panel's label showing a value incremented by 4 after every second. Can any body solve this problem..
<asp:ListView DataSourceID="sqldtsrclivepdt" ID="livepdtlst" runat="server">
<LayoutTemplate>
<ul class="productlist">
<asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
</ul><br />
</LayoutTemplate>
<ItemTemplate>
<li>
<asp:Panel ID="pnllivepdt" CssClass="paneldesign" runat="server">
<asp:UpdatePanel ID="updtpnlbid" runat="server">
<ContentTemplate>
<asp:Label ID="lblbidtimer" runat="server"></asp:Label><br /></ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="tmrpnl" EventName="Tick" /></Triggers>
</asp:UpdatePanel>
<asp:Timer ID="tmrpnl" Enabled="true" Interval="1000" OnTick="tmrpnl_Tick" runat="server"></asp:Timer>
</asp:Panel>
</li>
</ItemTemplate>
</asp:ListView>
static int a=0;
protected void tmrpnl_Tick(object sender, EventArgs e)
{
Timer tm = sender as Timer;
Panel p = tm.Parent as Panel;
Label lt = p.FindControl("lblbidtimer") as Label;
a++;
lt.Text = a.ToString();
}
View 4 Replies
Sep 4, 2010
I have 10 hyperlink controls. Depending on which hyperlink is pressed I want to pass a value to the target page. I think the easiest way would be to pass the value using URL of the hyperlink controls. Something like <asp:HyperLink ID="HyperLink1" NavigateUrl="~/News.aspx?id=>. I can pass just a value, but I want to pass a value from a variable.
<asp:HyperLink ID="HyperLink1" runat="server"
View 3 Replies
Jun 11, 2010
I have a javascript variable in the script tag. I am assigning a value to that variable and I want the same value to be assigned to the label control e.g. consider the sample code below :
<body><script type="text/javascript">
var a=window.opener.parent.document.getElementById('description').DataValue;
</script>
<
asp:Label
ID="lblSubject"
runat="server"
Width="142px"
Font-Bold="True"
Font-Size="10pt"
Font-Names="Arial"
>SUBJECT</asp:Label>
</body>
How do I assign the value of variable a to the label?
View 8 Replies
Jun 17, 2010
I have a simple user control which toggles between the visibility of a few images depending on the UserId. When the page is loaded for the first time, the userID is being assigned correctly (I'm debugging). However, there are two other buttons on the page for filtering the type of users, they are perform their functionality via Ajax (not the toolkit, but the normal javascript ajax) When one of these buttons are clicked, the user control cant get the userid, it always comes up as Zero. Oh, btw, the usercontrol is in a DataRepeater, so it occurs for each of the user.. all the time.. or thats the Idea. I have several other pages like this, (none of them have ajax) and the user control has no problems whatsoever.
My User control code:
[Code]....
And the Data Repeater is something like this:
[Code]....
Here, Immediately after the userControl <ucAB:....> line, I am printing the userid just to see if its valid (by <%# Eval("UserId") %> and the user id's are valid too. I dont understand why the User Control cant pick it up on ajax postback?
View 3 Replies
Oct 29, 2010
I have a property on a page called
public string productName { get; set;}
I want to access this in my usercontrol code behind. What's the right way to do it? Currently I am doing
(MyPage)Page).productName
But the user control is not compiling. My pagename is MyPage.
View 2 Replies
Apr 13, 2010
I'm creating a session variable in my .vb file and I'm able to display it in my .aspx but I can't seem to use it as a control in my asp:CompareValidator. The only way I can think to reference it on the .aspx page is with <%=Session("MyVariable") %> but
such constructs are not allowed in a validator with runat="server". But it seems like the validator must have that attribute and value.
Really what I'm trying to do is validate a user-entered number in a textbox against the one populated in that same textbox from the database. If the user replaces the textbox value with a smaller one I want to show an error message and prevent submit.
View 3 Replies
Sep 25, 2010
I have been alerted to the Query Extender control through previous posts, but I am still seeking the final part of my desired solution.
NB the following is written in conceptual English (programming specification) format, rather than actual asp code.
While I fully understand that I can use the QueryExtender control to pass a parameter from one web page to another, I do not see, and maybe this is not even possible, how I can pass a parameter of which field I want to select on.
Ideally I would like to be able to implement a query which is
SELECT tiles where 'Passed Variable Name' contains 'Passed Test Value'
such as would then generate, for example -
[code]....
I have only mentioned three in the concept above but there are actually about half a dozen different calling pages, and there could develop a few more over time.
View 1 Replies
May 17, 2010
I am new to web design so bear with me. I have an .aspx page with a user control at the top that is basically a container for an image. It serves as a banner spanning the entire page. The lower part of the page is a left and right sidebar with a main middle section.
The image is simply some text at the left layered over a background that fades from blue to white, top to bottom. Image size is 90 p. high by 1000 p. wide. How can I get this image to vary width withing the control along with the rest of the page when rendered under different screen resolutions?
View 1 Replies
Nov 26, 2010
How can i display the string variable data "234,345,567,678" into a listbox? i wish to parse the delimited string as seperate items.
View 4 Replies
Jan 24, 2011
I have a function that gets the position of a control.
[Code]....
All the function needs is an htmlcontrol being fed to it as the parameter (elemRef). I can declare a variable in Javascript of the same content page but different function and pass the parameter successfullly getting returned values. For example, if I have the following function:
function (getPosition)
{ var txtBox1 = document.getElemendById('<%=txtBox1.ClientID %>');
getPos(txtBox1);
}
I will get the coordinates of the control txtBox1. But how can I accomplish this if I am calling this function from a javascript function or codebehind of the Master Page, or codebehind of the same content Page.
View 4 Replies
Jan 14, 2011
I have a variable in an aspx file I need to use/recover it's value into an ascx web control that's in this aspx file. It's possible to do it? The aspx dynamically loads web controls depending the scenario, so this web control not allways is loaded.
View 2 Replies
Apr 11, 2010
Generally I want to pass string result of some control to other control or htm tag like without using specific classes in my ASPX page, only my control and what asp gives:
<a href="<MyControls:MyContr Param="Tech"/>">my link</a>
but this doesnt work - href is not executed, server treats it literally <MyControls:MyContr Param="Tech"/> so I would like to know it is possible to do it like in JSP pages:
- pass <MyControls:MyContr Param="Tech"/> to some variable $myVariable
- pass $myVariable to href like <a href="$myVariable" ?
View 2 Replies
Oct 8, 2010
I am trying access the row index on this GridView, but the e.CommandArgument gives me a value of an empty string "" , so the the error handler kicks in. What do you think I am missing.
[code]...
View 3 Replies
Jan 19, 2010
I'm looking for the correct syntax to get me the last row of a repeater item and use it in a literal below. As you can see I have the item index syntax already. assume that there is a repeater control surrounding the literal already.
I have already bound the data so it will not use obitemdatabound .
<asp:Literal id="Rpt_ItemCount" runat="server"
Text = '<%# (int) DataBinder.Eval(Container, ItemIndex"))%>'></asp:Literal>
View 6 Replies
Apr 8, 2010
I have a listview, that shows 8 rows until creating another page to navigate to to see the rest. I can't figure out where the limitation of the number of rows is coming from
View 7 Replies