473,721 Members | 2,186 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing Datalist items at run time

Hi ,

I am displaying 5 photos of a user(getting image path from database) and
binding them to hyperlink control and adding that Hyperlink control to
Datalist container in code behind file.

Now I want to change last 2 photos of user with another image while loading
the page.

My situation is "I want to hide/mask photos of user depending on the
permission level of who accessing the website.if one is paid member i want
to display all or for free members i need to display few.

............... . code ......

try

{

DataList1.ItemT emplate = new DatalistHyperLi nkColumn();

DataList1.DataS ource =ds1;
DataList1.DataB ind();

}

catch (Exception ex)

{

Response.Write( ex.ToString());

}

finally

{

PhotosConnectio n.Close();
}

}

public class DatalistHyperLi nkColumn : ITemplate

{

public DatalistHyperLi nkColumn()

{

//Add constructor stuff here

}

public void InstantiateIn(C ontrol container)

{

HyperLink hpl = new HyperLink();

hpl.DataBinding += new EventHandler(th is.BindLabelCol umn);

container.Contr ols.Add(hpl);

}

public void BindLabelColumn (object sender, EventArgs e)

{

HyperLink hpl1 = (HyperLink)send er;
DataListItem container = (DataListItem)h pl1.NamingConta iner;

String strVals =
Convert.ToStrin g(DataBinder.Ev al(((DataListIt em)container).D ataItem,
"ThumbImagePath "));

String lImagePath =
Convert.ToStrin g(DataBinder.Ev al(((DataListIt em)container).D ataItem,
"LargeImagePath "));

int pCount1 =
Convert.ToInt32 (DataBinder.Eva l(((DataListIte m)container).Da taItem,
"photocount1")) ;

hpl1.ImageUrl = "Photos/"+strVals;

hpl1.NavigateUr l = "Photos/web/" + lImagePath;

}

............... ............... ........
plz can one help me put..

Thanks in advance
Sanju
Sep 13 '06 #1
1 2390
You need to handle ItemDataBound event. In the event handler you can check
the permission level and hide/mask the photos in the item accordingly.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"sanju" <sa***@elogic.c o.nzwrote in message
news:OX******** ******@TK2MSFTN GP06.phx.gbl...
Hi ,

I am displaying 5 photos of a user(getting image path from database) and
binding them to hyperlink control and adding that Hyperlink control to
Datalist container in code behind file.

Now I want to change last 2 photos of user with another image while
loading the page.

My situation is "I want to hide/mask photos of user depending on the
permission level of who accessing the website.if one is paid member i want
to display all or for free members i need to display few.

............... code ......

try

{

DataList1.ItemT emplate = new DatalistHyperLi nkColumn();

DataList1.DataS ource =ds1;
DataList1.DataB ind();

}

catch (Exception ex)

{

Response.Write( ex.ToString());

}

finally

{

PhotosConnectio n.Close();
}

}

public class DatalistHyperLi nkColumn : ITemplate

{

public DatalistHyperLi nkColumn()

{

//Add constructor stuff here

}

public void InstantiateIn(C ontrol container)

{

HyperLink hpl = new HyperLink();

hpl.DataBinding += new EventHandler(th is.BindLabelCol umn);

container.Contr ols.Add(hpl);

}

public void BindLabelColumn (object sender, EventArgs e)

{

HyperLink hpl1 = (HyperLink)send er;
DataListItem container = (DataListItem)h pl1.NamingConta iner;

String strVals =
Convert.ToStrin g(DataBinder.Ev al(((DataListIt em)container).D ataItem,
"ThumbImagePath "));

String lImagePath =
Convert.ToStrin g(DataBinder.Ev al(((DataListIt em)container).D ataItem,
"LargeImagePath "));

int pCount1 =
Convert.ToInt32 (DataBinder.Eva l(((DataListIte m)container).Da taItem,
"photocount1")) ;

hpl1.ImageUrl = "Photos/"+strVals;

hpl1.NavigateUr l = "Photos/web/" + lImagePath;

}

............... ............... .......
plz can one help me put..

Thanks in advance
Sanju

Sep 13 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5479
by: Kaung Htut O via DotNetMonster.com | last post by:
Hi to all Is there a way to access Datalist Footer's Control properties from outside of datalist event. Pls note that I mean not a datagrid, only for datalist. Thanks Kaung Htut Oo
1
4567
by: Mike Malter | last post by:
I take it that the only way to add rows to a DataList control is through DataBind? If not, how do I manually add rows to a DataList control? I have searched everywhere and can't find an example anywhere other than through building a DataTable, and then doing a DataBind. Thanks. Mike
4
8302
by: jenn | last post by:
Hi Anyone knows how to access to a value of a row in a datalist. Something like this in datagrid Dim str = MyDataGrid.Cell(0).tex I would like something like this Dim str = DataBinder.Eval(MyDatalist.Items(count).DataItem, "customerId") but it doesn't work.
10
2849
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I have to add a datalist control. Using this datalist control I should be able to add edit, modify and cancel the items listed in this control. Here is how I designed. I used placeholder to add the controls dynamically to the page on the click...
5
13392
by: Patrick.O.Ige | last post by:
I'm binding a CheckBoxlist below in the ItemDataBound(the CheckBoxList is in a Datalist) By doing "li.Selected = True" i can see all the checkBoxes are selected. But what i want is to be able to get a Boolean value TRUE or FALSE when a checkBox is selected. When the checkBoxList was out of the DataList i used "OnSelectedIndexChanged" and it was returning what i wanted but if its in a
4
4038
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to work:( Thanks My CheckBoxList in the DataList Below
2
3647
by: Fabiano | last post by:
Please, i need to hide a Item(Collumn) of a DataList that is inside of another DataList based on some data that i my database returns. For a sample i created the code above, but it doesn't work. I tryed the visible property, everything. Tks in adv. Fabiano
6
9593
by: Paul | last post by:
I am trying to use a DataList and the ItemTemplate. I am binding the Datalist to a SQL query that gives me a list of Items with a Parent Category. I want to loop through all the items, but only print the Parent Category once, regardless of how many child items are in it. So my perfect output would look something like:
1
1576
by: David | last post by:
Hi, This one appears a little strange to me. Here is the scenario. I load a datalist the first time a page is run. The page has a !IsPostback and the datalist gets loaded at this point. I have a button on the page, where I want to read the contents of the datalist. As an example that I have found on MS...
1
3710
by: studen771 | last post by:
Thanks in advance to anyone who can help :) I have my datalist bound to a normal, single dimension string array (with three elements) as its data source. In the scripting for the datagrid, I have it creating a table element in the <HeaderTemplateand creating a row in the <ItemTemplatesection. The <FooterTemplateonly has a closing </tabletag within it. The problem: The datagrid is repeating all of the elements in the array as rows in...
0
9367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9131
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8007
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5981
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4484
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.