Forms Data Controls :: Make A Databound Control With A Custom Scrollbar?

Mar 22, 2010

I'm working on a website to showcase some of my bird photography, using ASP.NET 2.0 and C# with a SQLServerExpress backend.What I have right now is a ListBox bound to my database that displays a list of common names of birds and when the user clicks on an item in the listbox the main image on the page is changed to the image for that bird. For style reasons I want the listbox to always be a fixed size and because I specify the size (using CSS) a vertical scrollbar appears. My problem is that I want to provide my own images of arrows that go above and below the box such that when the user hovers over an arrow the box scrolls slowly and when the user clicks an arow the box scrolls quickly. Finally, my main problem is that I want to get rid of the ugly default vertical scrollbar that comes with ListBox.

Can you guys help me figure out how to do this? I don't mind using a different control other than ListBox as long as it is available in ASP.NET 2.0 and as long as it can be bound to my db. I also don't mind using JavaScript (which I'm sure I'll end up doing for the hover effects). Right now I'm fooling around with subclassing the ListBox control but I've never subclassed a control before so I'm somewhat clueless.

View 3 Replies

Similar Messages:

Forms Data Controls :: How To Make Gridview  With Scrollbar With Making Header Static

Dec 23, 2010

how to make gridview with scrollbar with making header static.

View 2 Replies

Custom Templated Control - To Modify Where Databound Data Is Output To?

Aug 31, 2010

Basically, I have a custom templated control with a custom data container class. When a developer adds an instance of my control to a page, they can define the controls in the LayoutTemplate however they like, as follows:

<ml:MyControl id="MyControl1" runat="server">

I would like my control to automatically move the "ml_errormessage" (databound content from Container.ErrorMessage - hard coded token in the property) to be a class of its containing element to make it easier for jQuery to use a selector to find the element and dynamically insert the error message client side. More importantly, I would like it moved out of the way so the class name doesn't get replaced by the content and jQuery can find it as many times as it needs to during the page lifecycle. In other words, I would like the output to look like this without the developer changing the input template or resort to using custom controls in the template:

<span id="MyControl1"><span>
<span class="ml_errormessage"></span>

I would like to move the value using the controls collection rather than resorting to string parsing of the output, if possible. However, when I interrogate the collection in an override of OnPreRender, the control in the template looks like this in the debugger:

System.Web.UI.DataBoundLiteralControl: {System.Web.UI.DataBoundLiteralControl} [code]...

As you can see the "ml_errormessage" value is nowhere to be found. Upon analysis of the DataBind event of the Control class using Reflector, I see that it delegates the binding behavior to each control. In other words, each control handles its own databinding. However, since I have no way of knowing in advance what control types will be in the template, how can this change be done?

Note: an acceptable alternative would be to add a new HtmlGenericControl (span) in the exact spot where the "ml_errormessage" is and add it as a class to this new control.On a side note, is there an easy way to get the control's output to indent for easy reading during debugging?

View 1 Replies

Web Forms :: How To Control Custom Templated Databound

Nov 11, 2010

I am fairly new to programming. I found this custom control that uses ajax to update the contents of the control and it is working perfectly. However, I need to access some of the labels and images in the databound event so I can set their values/properties appropriately, and am not sure how to go about adding additional code or accessing these in my custom control (I have been googling endlessly with no results). My code for the custom control is below.

Imports System
Imports System.Text
Imports System.IO
Imports System.Collections
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports Microsoft.VisualBasic
Namespace myControls
Public Class AjaxDivView
Inherits CompositeDataBoundControl
Implements ICallbackEventHandler
Private _itemTemplate As ITemplate
''' <summary>
''' The ItemTemplate is used to format each item from the data source.
''' </summary>
<TemplateContainer(GetType(DivViewItem))> _
<PersistenceMode(PersistenceMode.InnerProperty)> _
Public Property ItemTemplate() As ITemplate
Return _itemTemplate
End Get
Set(ByVal value As ITemplate)
_itemTemplate = value
End Set
End Property
''' <summary>
''' Register Javascript
''' </summary>
Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)
'Register Refresh Function
Dim eRef As String = Page.ClientScript.GetCallbackEventReference(Me, Nothing, "AjaxDivView_Result", "'" & Me.ClientID & "'", "AjaxDivView_Error", False)
Dim refreshFunc As String = "function AjaxDivView_Refresh() {" & eRef & "}"
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), Me.UniqueID, refreshFunc, True)
End Sub
''' <summary>
''' Iterate through the data items and instantiate each data item in a template.
''' </summary>
Protected Overloads Overrides Function CreateChildControls(ByVal dataSource As System.Collections.IEnumerable, ByVal dataBinding As Boolean) As Integer
Dim counter As Integer = 0
For Each dataItem As Object In dataSource
Dim contentItem As New DivViewItem(dataItem, counter)
counter = counter + 1
Return counter
End Function
''' <summary>
''' Render this control's contents in a Ul tag
''' </summary>
Protected Overrides ReadOnly Property TagKey() As System.Web.UI.HtmlTextWriterTag
Return HtmlTextWriterTag.Div
End Get
End Property
''' <summary>
''' Render my contents to a string and send the result back to the client
''' </summary>
Public Function GetCallbackResult() As String Implements System.Web.UI.ICallbackEventHandler.GetCallbackResult
Dim builder As New StringBuilder()
Dim sWriter As New StringWriter(builder)
Dim hWriter As New HtmlTextWriter(sWriter)
Return builder.ToString()
End Function
''' <summary>
''' Whenever I get called through AJAX, rebind my data.
''' </summary>
Public Sub RaiseCallbackEvent(ByVal eventArgument As String) Implements System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent
End Sub
Public Class DivViewItem
Inherits WebControl
Implements IDataItemContainer
Private _dataItem As Object
Private _index As Integer
Public ReadOnly Property DataItem() As Object Implements System.Web.UI.IDataItemContainer.DataItem
Return _dataItem
End Get
End Property
Public ReadOnly Property DataItemIndex() As Integer Implements System.Web.UI.IDataItemContainer.DataItemIndex
Return _index
End Get
End Property
Public ReadOnly Property DisplayIndex() As Integer Implements System.Web.UI.IDataItemContainer.DisplayIndex
Return _index
End Get
End Property
Protected Overrides ReadOnly Property TagKey() As System.Web.UI.HtmlTextWriterTag
Return HtmlTextWriterTag.Div
End Get
End Property
Public Sub New(ByVal dataItem As Object, ByVal index As Integer)
_dataItem = dataItem
_index = index
End Sub
End Class
End Class
End Namespace

View 5 Replies

Forms Data Controls :: How To Make AutogenerateColumn="false" In Custom GridView Server Control

Mar 4, 2011

I've a ServerControl inherited from GridView. What is the way (best) to make AutogenerateColumns="false" by default in custome control.

but User still should have option to make it true any time.

View 2 Replies

C# - Getting Eval To Work In A Databound, Templated Custom Control?

Sep 29, 2010


I'm putting together a templated, databound control. Presently it works with the following syntax...
<cc:ItemChooserControl ID="ItemChooser" runat="server">
<h4><%# DataBinder.Eval(Container.DataItem, "DisplayName") %></h4>


What I would like though is that the shorter, simpler Eval would work instead.
<h4><%# Eval("DisplayName") %></h4>
What I get however when using straight Eval is an error:
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.


I'm databinding to a custom HtmlTableCell...
public class TitleTemplateTableCell: HtmlTableCell, INamingContainer
private object m_DataItem;
public virtual object DataItem
get { return m_DataItem; }
set { m_DataItem = value; }

With the following custom DataBind (non-related code removed)...

foreach (object dataItem in dataSource) {
TitleTemplateTableCell title = new TitleTemplateTableCell();
TitleTemplate.InstantiateIn(title); // TitleTemplate is the template property
title.DataItem = dataItem;

View 1 Replies

Forms Data Controls :: Databound Treeview Control Using .net?

May 21, 2010

i am developing a tree view component which should be data driven and amendable instead default layout provided by .net can we change that proper hierarchial structure like organization chart is there any chance to provide with an hyperlink to redirect other page or content view control below to display the content related to it.

i am trying to use silverlight with c#.

View 2 Replies

C# - Which Databound Control Should Be Use For Nested Databound Controls?

Dec 7, 2010

I want to render something like this (with ASP.Net Controls in the codebehind):

<li class="first"><h1>This is a caption</h1></li>
<li><a href="#" title="" target="_self">Foo</a></li>
<li><a href="#" title="" target="_self">Foo1</a></li>
<li><a href="#" title="" target="_self">Foo2</a></li>
<li><a href="#" title="" target="_self">Foo3</a></li>
<li><a href="#" title="" target="_self">Foo4</a></li>
<li class="first"><h1>This is a another caption</h1></li>
<li><a href="#" title="" target="_self">Foo5</a></li>
<li><a href="#" title="" target="_self">Foo6</a></li>
<li><a href="#" title="" target="_self">Foo7</a></li>
<li><a href="#" title="" target="_self">Foo8</a></li>
<li><a href="#" title="" target="_self">Foo9</a></li>
<li><a href="#" title="" target="_self">Foo10</a></li>
<li><a href="#" title="" target="_self">Foo11</a></li>

The amount of li elements that will be rendered into each ul is determined at runtime. Each link in a li belongs to into a specific ul (the one containing a specific caption. Imagine this as a kind of a treeview with nodes and subnodes) During the bind Event I need access to an ASP:HyperLink that will be rendered into the a-element. Which databound ASP.Net control should I pick for this? Looks like a repeater in a repeater, which should make the databinding process ugly. I'm thinking about creating this HTML-Output with StringWriters myself.

View 1 Replies

How To Create Custom Multi-templated Tree Databound Control

Apr 5, 2010

I dont want to use's TreeView control. I want to create a custom template databound control with multi template support like -


My data is like -

class Employee
string EmployeeName
List<Employee> Employees

Does anyone know how to accomplish it?

View 1 Replies

How To Build A GridView Like DataBound Templated Custom Server Control

Apr 13, 2010

I am trying to develop a very simple templated custom server control that resembles GridView. Basically, I want the control to be added in the .aspx page like this:


I know that what I want to achieve is pointless and that I can use DataGrid to achieve it, but I am giving this very simple example because if I know how to do this I would be able to develop the control that I need.

View 1 Replies

Forms Data Controls :: Refresh Databound Control On AJAX Tab?

Jan 6, 2010

I have an AJAX tab container with 2 panels within aspx page. Each panel hosts an ascx control. Each control contains GridView and FormView that are databound - 1st control to the parent table and 2nd - to the child. The 2nd control/tab contains standard DropDownList that is bound to the parent values so the user can select a parent to create "child" for. everything works fine except when the parent (on the 1st tab control) is created/updates the ObjectDataSource on the 2nd tab does not getting refreshed. Only after refreshing the hole page I can see the new "parent" value in the ddl on "child" page. I use strongly typed dataset. How I can programmatically refresh the DataSource? Simple rebinding didn't make a dent. Do I need to refresh page, the tab container, tab panel?



View 1 Replies

Forms Data Controls :: Use Eval Or Bind In A Databound Control?

Sep 8, 2010

I have a repeater I've databound with a generic arraylist from a LINQ query (.ToList() ) in the code behind.

I was using

<%# Bind("FirstName")%> but noticed
<%# Eval("FirstName")%> works just as well.

Is it better to use Eval or Bind? or does it depend on the situation?

View 3 Replies

Forms Data Controls :: Adding Calculated Fields To A Databound Control?

Oct 14, 2010

I need a form that displays three columns drawn directly from a database (no problems here) as well as two fields that require some complex calculations. Not only am I lost as to how to incorporate the calculations into the control, I don't know exactly how to write the calculations. I am working in Visual Web Developer 2008 with Vb.NET.

The first of the two fields should take the sum of all payments made by a given customer and divide it by a DailyMembershipRate, returning a DaysPaid variable. It should take this variable and a CustomerSince field for that particular customer and calculate a PaidThrough field.

The second of the two columns similarly requires the DaysPaid variable described above. It should subtract the CustomerSince field from the current date and return the value in days, giving a MembershipDays variable. Finally, it should subtract MembershipDays from the DaysPaid variable, again returning a value in days, and then multiply this by the DailyRate value for a Credit/Deficit field.

I realize this is a lot, but I haven't been able to find any documentation either online or in VWD or ASP.NET texts on this topic. I could really use some fellow user input.

View 4 Replies

Forms Data Controls :: How To Set DataList's EditItemTemplate To User Control And Databound It

Feb 24, 2011

I have DataList control and I want to assign to it's edititemtemplate some User Control. The problem is I can't find when I should databound UserControl to data, as my UserControl doesn't have static look (it renders different depending on some property values and datasource).

I was try to simply set my user control in edititemtemplate

<uc:MyUserControl id="myUserControl1" runat="server" />

and then bind it to data in ItemDataBound event handler, but it remains empty

if(e.Item.ItemType == ListItemType.EditItem)
var p = (Pair)DataBinder.GetPropertyValue(e.Item.DataItem, "Key");
((AnnouncementUserControl) e.Item.FindControl("userControl1")).RepeaterDataSource =
_templateWorker.ReturnTemplateByAnnouncementId(Convert.ToInt32(p.First), true);

how can I databound my control, or another approach which will make me avoid this problem?

View 2 Replies

Forms Data Controls :: Adding A Calculated Field To A Databound Control?

Oct 19, 2010

I'm using a gridview to extract a set of records. I need to add another field to the gridview, which can calculate the difference between a date associated with each record and the current date.

View 6 Replies

Forms Data Controls :: Passing The Underlying Data Of The Databound Control?

Mar 30, 2010

In my web page i have a dropdown box. Say like i have to bind EmployeeName to this dropdown box to show up as items.

I am using a dataTable to bind to this grid by having two columns in DataTable (EmployeeId and EmployeeName). But i am only binding the EmployeeName to the dropdown list box.

In the UI, after the user selects an Employee, I need to pass that employee's id to a function. Is there any way, i can directly pass the underlying data (EmployeeID in the DataTable attached to this dropdown), when the user selects the EmployeeName from the dropdown. Or i will have to make a roundtrip to the database and get the selected Employee's Id and then pass it to the function.

View 2 Replies

Forms Data Controls :: Eval(), XPath(), And Bind() Can Only Be Used In The Context Of A Databound Control?

Mar 9, 2010

I have a big problem...I have made a page has a Data FormView controland the insert template of this Formview control has DropDownList to allow the user to choose section (SectionsDDList)..and there's also another DropDownList allow the user to choose a teacher (TeachersDDList)...more infothe SectionsDDList get the section list from SqlDataSource control which the "Select Command" of is:"SELECT section_id,section_id FROM sections"the TeachersDDList get the teachers list from another SqlDataSource control which the "Select Command" of is:"SELECT teacher_id,teacher_name FROM teachers WHERE (section_id = @section_id)"finallyI want the TeachersDDList to be filled with teachers according to the selected section from the SectionsDDList...So,I enable the Auto postBack function of the SectionsDDListand add the next code for the SectionsDDList_SelectedIndexChanged event:TeachersDataSource.SelectParameters["section_id"].DefaultValue = ((DropDownList)sender).SelectedValue;be aware that both of the SectionsDDList & TeachersDDList have been Bounding to a column...and the problem I have faced is that:Exception Details: System.InvalidOperationException: Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.maybe you want to know the Stack Trace:[InvalidOperationException: Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.]

System.Web.UI.Page.GetDataItem() +93
System.Web.UI.TemplateControl.Eval(String expression) +33
ASP.cpanel_managecourses_aspx.__DataBinding__control82(Object sender, EventArgs e) in


View 8 Replies

Web Forms :: Make A Custom Login Control

Apr 25, 2010

need some guidance on how to make a custom login control where a user needs to input 3 field of input e.g Username, Password and Member ID number in order for them to be able to access a website.

View 3 Replies

Forms Data Controls :: Custom Gridview / Insert The Custom Dropdown Button Using Server Control For Each Column?

Aug 18, 2010

i've created a webform with one gridview having connected with the database using datasource. i.e password database with three colomn .

now want to insert the custom dropdown button using server control for each column.

when i select the dropdown list the list should display the value as required.

e.g if i click the uname dropdownlist then it should show the list of names.

if i click on pwd dropdownlist then it should show the list of numbers.

if i select any one of the value in the dropdown list then it should insert into the


can i get code on this type of question...?

View 3 Replies

Forms Data Controls :: How To Use A Custom Wizard To Make Entries In Multiple Tables

Apr 8, 2010

I'm using Visual Studio 2008 with SQL Server Express databases in my .net 3.5 website

I have three tables I'd like to make entries to when the user completes a wizrd i've setup on a web form.

The First Step - The user enters basic information about their "Case". The table looks like so:

db_Cases - CaseId PK auto int, CustomerId, etc fields

The Second Step - The user enters information about the "Debtors" that are related to this "Case". Think of this as being products....The only difference is these records wont be used over and over again like a product would. The user may need to enter data about several "Debtors", just like if you needed to show several different products on an invoice. For example the user may need to enter information about a husband and wife. This means two entries in the "Debtors" table. The table looks like so:

db_Debtors - DebtorId PK auto int, etc fields

The Third Step - Here's my problem. This step needs to make entries into a third table called "CaseDetails". Again, this is just like if you were creating an invoice with several different products on it, where you would want to get a subtotal of each product's cost. The table looks like so:

db_CaseDetails - CaseDeatailId PK auto int, CaseId int, DebtorId, int

* When this table is later viewed, It will reflect all "Debtors" attached to the specific "Case" being viewed.

The first two steps aren't a problem, I pretty well have that handled in the wizard. BUT How do I create the entries in the "CaseDetails" table when the user finishes?

My idea right now is..... Considering the "Debtors" will be re-used but only on rare occations, I'm thinking I should just add the "CaseId" that was created in step one, to the "Debtors" table at the same time the "Debtor" is created. So the table would look like so.

db_Debtors - DebtorId PK auto int, CaseId int, Name, Address, etc

View 1 Replies

Forms Data Controls :: Custom Grid View Header - Grid View Row Created Event Versus Gridview Row Databound Events

Aug 24, 2010

It happened to add an extra Gridveiw Header in row_databound event , It did worked fine on !Postback but disappered on Page.Postback . Quick google search guided me to move the event to Row_Created event and every thing is okay .

Can any expert post some pointers , differnces between grid row_created vs row_databount with some sample table data created dynamically behaviour of both the events in !Postback and page.Postback .

View 2 Replies

Forms Data Controls :: How To Make A Custom Grid / Insert / Edit / Delete Page

Jul 9, 2010

Lets say that i want to make a ADMIN page for articles.

1) I show all my articles on lines
2) Each article has an EDIT BUTTON and INSERT NEW button
3) When I click on the EDIT BUTTON, it opens a CUSTOM page where i can Edit my article.
4) When i click on the INSERT NEW BUTTON it opens the same CUSTOM page where i can Insert my article.

I was trying to do it with Gridview and Formsview.

View 8 Replies

DataSource Controls :: Make A LINQ Databound Record Update Page?

Mar 15, 2010

I am creating a database frontend in aspx/C# using LINQ to MSSQL. It has two pages: a main page which lists all of the records, and a page that appears when the user click the "Edit" button next to one of the list items for the user to edit a record.The database table has about 70 user-editable fields. I need to make the edit page, allowing the user to update/insert records. There are a couple ways I can think of make an edit page:Using a LinqDataSource and FormViewUsing a LinqDataSource and DetailsViewManually retrieve the value for each field and set the value for each field directly from Linq (e.g. "projectIDLabel.Text = Convert.ToString(thisRecord.Project_ID)"What would be the best way to design this?

View 4 Replies

Data Controls :: How To Use EVAL Function Outside GridView DataBound Control

Dec 29, 2012

this is my hyperlink code that is in gridview

<asp:HyperLink ID="lnkRemove2" runat="server" CssClass="LBP3E" Text = "more..." NavigateUrl='<%# "state/view.aspx?BehCode=" + Request.QueryString["BehCode"] + "&Id=" + Eval("Id") %>'></asp:HyperLink>

I want do some thing like that for my button control that is not in gridview it is out of grid view...HOw I can do it?

View 1 Replies

Forms Data Controls :: Positioning Scrollbar?

Sep 6, 2010

I have a listview with multiple records inside a div whose overflow property has been set to enable scrollbars. Now I have another search panel in which If i click on a particular item the corresponding item in the listview gets selected. But the problem is that the item gets selected but the user cannot view it if its way down on the list.I also want the scrollbar to move in order to let the user show the selected item.

View 8 Replies

Copyrights 2005-15, All rights reserved