C# - How To Define Variable In Repeater

Jan 26, 2010

I like to handle and compare a lot of date times in my repeater even I have to work more than one time with the same.

It's a bit ugly, to cast everywhere the Eval("MyDate") like ((DateTime)Eval("MyDate")) to substract 2 datetimes or to compare it, even if you have to do this more than in one operation.

I thought of saving all the evals in a var at start of the repeater?

DateTime mydt1 = Eval("myDate");
DateTime mydt2 = Eval("mydate");

after that, it's easy to do any operations in the whole repeater. Hope you understand my idea. Is this possible? I tried short but everytime errors.

mydt1 - mydt2....

View 2 Replies


Similar Messages:

C# - How To Define A Global Variable In Web App

Nov 13, 2010

I want client access a data center but without use database , so I want my web app can retain a global or Application session variable, that contains the data, every client can access the same data... I am try to declare in golabl, but seem it only can store String but others ..

View 5 Replies

C# - Define A Variable Of Different Types?

Feb 8, 2011

to define a variable/property of more than one type. Let's say i want a property TextWebControl that is a WebControl and also implements Web.UI.ITextControl(f.e. like a TextBox or Label). But i don't want to enforce that it is a TextBox or Label, but only one that inherits from WebControl and also implements ITextControl so that it also would work with controls added in future releases of .Net-Framework.

.Net-Framework 4.0

Edit: I have retagged the question and added VB.Net because it's my default language. Normally it's no problem for me to understand C# also, but i must admit that it's difficult to translate generic stuff to VB.Net without experiences and it's also better documentated in C# than in VB. So i would appreciate(and aceept) a working example of a VB.net generic type of ITextControl/WebControl.

From Marc's answer i understand that i need a generic class. But how do i instantiate it in SomeClass? This won't compile:

Class SomeClass
Public Property info As InfoControl(Of WebControl, ITextControl)
End Class

View 3 Replies

How To Define A Property Instead Of Public Variable In C#

Mar 28, 2011

public static string SEARCH_STRING = "searchkey";
string key=Request.QueryString.Get(SEARCH_STRING);

How to change the above code to make SEARCH_STRING be accessed using a Property(get; set;) instead of a public variable

View 8 Replies

State Management :: How To Define A Global Variable In A Page

Oct 31, 2010

I have to define a global and unchangeable variable in a web page. I used static variable but its content is the same for all users that use the page and it is bad. I dont want use Session variable.

View 5 Replies

Forms Data Controls :: Repeater Paging - Retrieve Hyperlink Variable Inside Repeater?

Jul 12, 2010

I have repeater in which I have 2 hyperlink in the footer of the repeater and I want that the hyperlink can navigate from the page_load

View 2 Replies

MVC :: Define "Variable" In Razor Layout?

Jan 6, 2011

How can I define a value in a Razor Layout page to be used in the views that use that layout?

View 2 Replies

Using Variable For Repeater Eval?

Mar 22, 2011

Can I use variable in eval in repeater? Or how can I use it?

For example:

<%# DataBinder.Eval(Container.DataItem, lngHome) %>

Code behind in form load:

[code]....

I have 2 fields in database table: eng_detail and tr_detail

So how can I use like this <%# DataBinder.Eval(Container.DataItem, lngHome) %>?

View 2 Replies

Setting Session Variable On Repeater Item Click?

Mar 1, 2010

first off I can't post the code, so I will do my best to try to explain what I am trying to do. I have a repeater with three literals (a member ID, a name, a uservalue) and three hyperlinks. Each of the hyperlinks goes to a different page (obviously).What I am trying to do is when the user clicks on one of the hyperlinks, (doesn't matter which one because the three literals need to be put into session variables regardless) I want the session variables set to the literal values before calling the next page.How do I get the session variables set when the user clicks on one of the hyperlinks?

View 9 Replies

Forms Data Controls :: Assigning A Variable From Repeater Value?

Jan 1, 2010

trying to get something to work, which I think should be extremely easy.

I'm grabbing a value from my database with a repeater, and want to assign the value to a variable that I can parse and then send into javascript. 'videofile' is the variable from the database, and I want to assign the value to 'vidfile', parse it, and then inject into javascript:

<asp:Repeater ID="Repeater3" runat="server" DataSourceID="SqlDataSource11">

View 1 Replies

Forms Data Controls :: Pass Variable With Repeater Hyperlink URL

Jan 15, 2010

I query the database to get the VideoName and VideoURL of the videos held in my database (Videos saved on the file system with their location stored in the database) then bind the query results to a repeater with the following code

protected void Page_Load(object sender, EventArgs e)
{
// Variables declaration
string strConnString = ConfigurationManager.ConnectionStrings["vidConnectionString"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(strConnString);
SqlCommand sqlcmd = new SqlCommand("SELECT [VideoName], [VideoURL] FROM [Video]");
SqlDataReader sqlReader;
sqlConn.Open();
sqlcmd.Connection = sqlConn;
sqlReader = sqlcmd.ExecuteReader();
VideoRepeater.DataSource = sqlReader;
VideoRepeater.DataBind();
sqlConn.Close();
}

and put a hyperlink into the repeater to list all the VideoName's this works fine but I want to pass the VideoURL to the next page I am using NavigateUrl="PlayVideo.aspx?VideoURL='<%# Eval("VideoURL") %>'" but when I try and load the Page I get the error saying The server tag is not well formed. the whole repeater code is

<asp:Repeater ID="VideoRepeater" runat="server" >
<ItemTemplate>
<asp:HyperLink ID="VideoLink" NavigateUrl="PlayVideo.aspx?VideoURL='<%# Eval("VideoURL") %>'" runat="server"><%# Eval("VideoName") %></asp:HyperLink>
</br>
</ItemTemplate>
</asp:Repeater>

I'm sure i've just got the hyperlink navigateURL wrong put not sure how else to pass the VideoURL variable

View 9 Replies

Forms Data Controls :: How To Pass Session Variable As A Parameter To Inline Function Written Inside A Repeater

Jun 26, 2010

I am working with a repeater control for a reporting purpose.

I have 2 repeaters one inside another , i hvae to bind the second repeater with the help of function which is having two parameters to pass in it

<asp:Repeater
ID="Rptgsaaccount"
runat ="server"
DataSource ='<%#bindcourse(Eval("Session_Id"),2nd parameter)%>'>

the first parameter is i am easily getting from outer repeater, but the second parameter value is exist on the server side and in a session variable

i have to pass this server side session variable value in above mentioned function as a second parameter .

View 2 Replies

Web Forms :: Implement One More Repeater Control Inside Existing Repeater Control (Nested Repeater)

Feb 3, 2014

I am using a repeater control and i want to use one more repeater control inside the existing repeater control . 

Like this:

<asp:Repeater ID="Repeater1" runat="server">    <HeaderTemplate> </HeaderTemplate>       
<ItemTemplate>
<!-- start child repeater -->     Here I want to use one repater control      <!-- end child repeater -->
</ItemTemplate>
</asp:Repeater>

View 1 Replies

C# - Nesting Repeater In Gridview: Hiding Gridview Row And Repeater Header If Data Is Not There In Repeater?

Apr 21, 2010

I have nested a repeater control in Gridview. Right now it is showing gridview rows and repeater header for every case(whether data is there or not for that particular grid view row in the repeater control). I want to hide the gridview row and repeater control header when there is no data present for that particular gridview row. That case I handled at code level by filtering the resulted data table.

Now the another problem I am facing: I have allowed the paging on the gridview i.e. pagesize 3. When page loads it works fine, but when I go to page 2 then it generates following error: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

Below is the code to fill the grid, paging and fill repeater on rowdatabound event of grid.

[code].....

View 1 Replies

JQuery :: Grab A Global Variable Or Session Or View State Variable In The Javascript?

Dec 9, 2010

can we grab a global variable or Session or View State variable in the javascript or using jquery?

View 2 Replies

State Management :: Public Variable Vs Session Variable To Store Logged In UserID

May 17, 2010

I have a web application which uses a session variable to store the logged in userid. If no user is logged in, of course this variable will be empty and the contents displayed on my website are meant for guests. If there is a user logged in, the user specific controls/access/links will then be a displayed.

I am now having issues with my hosting where on shared application pool, the worker recycle is triggered every 90 minutes, this will clear sessions causing all my users to be logged out. I opted for a dedicated application pool, which got worse because I am only allocated 50MB memory limit and if this is reached, the worker recycle is triggered and I lose my sessions again. I have tried as much as possible optimization techniques, e.g. dispose where possible, close connections, disable viewstate for static controls etc but my memory per instance keeps building up from page to page without any signs of improvement. I don't use loops nor store huge objects like bitmaps etc but my sessions are now gone even faster than 90 minutes in shared application pool before.

I have considered using SQL Session State but there isn't a simple guide on using this with MySQL. I am getting desperate and considering using a public variable, a string as a replacement to store logged in user id instead of in a session variable. I am pretty sure this will solve my issue with sessions being recycled but are there any negative consequences of doing this? One problem I can think of is if the user closes the browser, the system will never know that the user is now logged out and this public variable should be nothing. In this scenario, will the GC eventually clear this abandoned public variable.

View 10 Replies

Web Forms :: Convert System.Drawing.Image Variable To Byte Variable?

Oct 7, 2010

I got a variable of type System.Drawing.Image and need to convert it to a variable of type byte so I can store the image in the database. Can someone show me how to do that in VB.NET code.

View 2 Replies

C# - Hidden Variable Vs Server Variable Accessing On Client Side In Javascript

Jul 14, 2010

I'm evaluating two options of accessing a server side data on client side. Little bit confused about the efficiency or may be you can call it as finding best approach to do it.

I need to access a server side data may be an integer value in javascript on client side. I know about two options to do it.Create a public variable or property on server side and set it to javascript variable on client side as below:

var value = eval(<% =value %>);

Create a asp hidden variable and set value in this hidden variable from server side and access it through javascript using document.getElementById().

Which is the best approach and what are the pros and cons?

View 1 Replies

Declare Variable In C# / Use VAR (explicit Declaration) Or The DataType When Declaring A Variable (implicit)?

Sep 7, 2010

Possible Duplicate: Use of var keyword in C# Hi, I am pretty new in C#,I would like to know the best practices in declaring variables.I know it is possible to use VAR (explicit declaration) or the DataType when declaring a variable (implicit).

View 3 Replies

BC3016: Variable 'myConnection' Hides A Variable In An Enclosing Block?

Jul 16, 2010

I'm am not quite sure why I am getting this error.

Dim numUsers as Integer
Using myConnection as New System.Data.SqlClient.SqlConnection("Data Source=(local);InitialCatalog=dbtest;Integrated Security=True")
Dim queryString As String = "SELECT COUNT(*) AS Num_Of_User FROM tblusers WHERE username=@username AND password=@password"
Using myCommand as New System.Data.SqlClient.SqlCommand(queryString, myConnection)
myConnection.Open
myCommand.Parameters.AddWithValue("@username", requestName)
myCommand.Parameters.AddWithValue("@password", requestPass)
numUsers = myCommand.ExecuteScalar()
End Using
End Using

This error occurs on the first using statment.

View 1 Replies

Define The Selected Value For This?

Sep 22, 2010

<select name="MessageType" style="width: 151px">
<option value="P">P - Proprietary</option>
<option value="B">B - BCBSA</option>
<option value="S">S - Place Specific</option>
</select>

How to set the selected value for this Dropdownlist box?

<%=p.MessageType%>.. this is the value I am getting from database so that In my Grid what ever the Value coming form database it will show in the Dropdownlistbox on the Grid now its showing me as Default value P even Database value B

View 5 Replies

Variable Hides A Variable In An Enclosing Block Error

May 14, 2010

have a look at this simple code snippet

[Code]....

Here second declaration of x gives error that "variable 'x' hides a variable in an enclosing block. I wonder why this error is not given for second 'i' variable declared in second for loop?

Since i am declaring second x in a separate for block, why this error is given for variable second x ?

View 4 Replies

C# - Temporary Or Session Variable - Want To Add A Decimal Number To This Variable

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

Forms Data Controls :: Repeater Inside A Repeater (dataBound) Code Behind?

Jan 31, 2010

got an example of a repeater inside a repeater (dataBound) code behind?

View 3 Replies

Forms Data Controls :: ImageButton Inside A Repeater That Is In Another Repeater & Events?

Jan 18, 2010

I have a user control that displays a shopping cart in an ecommerce application.

The main cart display is a repeater that renders as a html table. In one of those table columns, there is another repeater to display people associated with the products int he cart (it's a repeater in case there is a line item >1 with multiple people).

I've added an ImageButton that I want to use to change the person associated with the item. At first, when I'd click on it I was getting this error:

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

So as an experiment I disabled EventValidation on the page (not the control it's self) and now I do not get an error, but I also do not ever hit the breakpoint I set in the innermost repeater's ItemCommand event.

So I wonder how I might do this without disabling EventValidation, because this control will show up on multiple pages and we don't want to edit them all. Also, I'll need to know not only the repeater containing the control's row that the event came from but also the row index of the repeater containg this one. Is this possible?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved