Monday, February 21, 2005
Tree Structure
Today I learnt how to use the data tree structure from an article. i have the code in wansdyke-intranet..
I tried using the code provided. It depended that I compiled the code.. But I worked out a simple sample with the functions provided. It is working fine..
Friday, February 18, 2005
Dynamic Image Display using javascript
I had this requirement. I was displaying images for moderation in a datagrid and was displaying this in a different resolution. If the user wants to view the image without opening a popup or going to server side I used javascript to do this.
DataGrid has an event OnItemDataBound. After a row is added in this event I attach an attribute "onclick" and the javascript function that is to be displayed.
I have a image control and onclick in the image control I display the full sized image. So moderator knows the size of the image and how it will look etc.. and then decide to accept or reject it.
Swarna
MultiSelect In datagrid.
http://www.codeproject.com/aspnet/Multi-select_Dataagrid.asp
Follow this article..
To select a random record from database from the latest 5 entries.
I have a a table named cms_imagelib and I would like to select a random record from the lasted added 5 records.. I used the following query to retrieve the required record..
Select newID(),a.imageID,a.ImageName as ImageName from cms_ImageLib as a where ImageID in
(Select top 5 ImageID from cms_imagelib where active='1' and moderated='1' order by creation_time) order by newID();
Thursday, February 17, 2005
To select first n characters without truncating a word.
In the Select query select the number of characters required.
while displaying in the datagrid.. use this
<%# DataBinder.Eval(Container.DataItem, "Article").substring(0,DataBinder.Eval(Container.DataItem, "Article").lastIndexOf(" ")+1)%>
Populating Textbox from xml file
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim reader As XmlTextReader = New XmlTextReader (Server.MapPath("abc.xml"))
Do While (reader.Read())
Select Case reader.NodeType
Case XmlNodeType.Element
Select reader.LocalName
Case "name":
name.text = reader.ReadString()
Case "address":
address.text = reader.ReadString()
End Select
End Select
Loop
The Xml file I used
<?xml version="1.0" encoding="iso-8859-1"?>
<sample>
<name>Swarna</name> <address>Bristol</address></sample>
Coloring the DropDownList
Today I came upon a request about coloring the Dropdownlist list items with different colors. I found that it could not be done as the
I found from the web that we can do this by adding an attribute to it.
iterate through the listitems and then add the Style atrribute
For i = 0 To ddl.Items.Count - 1
ddl.Items(i).Attributes.Add("style", "color:#cccccc")
Next
