473,749 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

datalist control

Hi,

How do I access the cells of a table that is located in a datalist control ?
I have the datalist control and some asp controls in it up n it is working
fine. My datalist is bound to a dataset.

I want to put in an if-else statement that states that if an array element
equals 1 (default 0), then the bgcolor of a particular cell is RED. Below I
have given a sniplet of my code:

MyDataList.Data Source = dsSA.Tables["StudentAns wer"];
MyDataList.Data Bind();

//array of 20 elements, of value either 1 or 0.
int [] setmarkcolor = (int[])Session["marked"];
eg. setmarkcolor[0] = 1;

This is in my .aspx file and I have given a sample of the cell that I want
to change the bgcolor below:

<asp:datalist id="MyDataList " Runat="server" RepeatColumns=" 0"
OnItemDataBound ="MyDataList_It emDataBound">
<ItemTemplate >
<TABLE id = "TableR">
<TR align="center">
<TD style="WIDTH: 18px; HEIGHT: 23px"><A href="Question. aspx?
questionId=1">1 .</A>
</TD>
<TD style="WIDTH: 149px; HEIGHT: 23px" bgcolor="#00fff f"><%#
DataBinder.Eval (Container.Data Item, "studentAnswer1 ")%>
</TD>
</TABLE>
</asp:datalist>
I hope my explanation is understandable. If not, just ask n I will clarify
further.
TIA.
Andrew.
Nov 19 '05 #1
2 1456
Hi Andhrew

change tr/td as servre tablecell/tablerow... and access the same control in
the item databound using tablecell t = e.Item.FindCont rol("UR Cell ID");
and now t.BackColor = UR Color;
Hi,

How do I access the cells of a table that is located in a datalist control ?
I have the datalist control and some asp controls in it up n it is working
fine. My datalist is bound to a dataset.

I want to put in an if-else statement that states that if an array element
equals 1 (default 0), then the bgcolor of a particular cell is RED. Below I
have given a sniplet of my code:

MyDataList.Data Source = dsSA.Tables["StudentAns wer"];
MyDataList.Data Bind();

//array of 20 elements, of value either 1 or 0.
int [] setmarkcolor = (int[])Session["marked"];
eg. setmarkcolor[0] = 1;

This is in my .aspx file and I have given a sample of the cell that I want
to change the bgcolor below:

<asp:datalist id="MyDataList " Runat="server" RepeatColumns=" 0"
OnItemDataBound ="MyDataList_It emDataBound">
<ItemTemplate >
<TABLE id = "TableR">
<TR align="center">
<TD style="WIDTH: 18px; HEIGHT: 23px"><A href="Question. aspx?
questionId=1">1 .</A>
</TD>
<TD style="WIDTH: 149px; HEIGHT: 23px" bgcolor="#00fff f"><%#
DataBinder.Eval (Container.Data Item, "studentAnswer1 ")%>
</TD>
</TABLE>
</asp:datalist>
I hope my explanation is understandable. If not, just ask n I will clarify
further.
TIA.
Andrew.

Nov 19 '05 #2
thanks

"HARI PRASD BARU" wrote:
Hi Andhrew

change tr/td as servre tablecell/tablerow... and access the same control in
the item databound using tablecell t = e.Item.FindCont rol("UR Cell ID");
and now t.BackColor = UR Color;
Hi,

How do I access the cells of a table that is located in a datalist control ?
I have the datalist control and some asp controls in it up n it is working
fine. My datalist is bound to a dataset.

I want to put in an if-else statement that states that if an array element
equals 1 (default 0), then the bgcolor of a particular cell is RED. Below I
have given a sniplet of my code:

MyDataList.Data Source = dsSA.Tables["StudentAns wer"];
MyDataList.Data Bind();

//array of 20 elements, of value either 1 or 0.
int [] setmarkcolor = (int[])Session["marked"];
eg. setmarkcolor[0] = 1;

This is in my .aspx file and I have given a sample of the cell that I want
to change the bgcolor below:

<asp:datalist id="MyDataList " Runat="server" RepeatColumns=" 0"
OnItemDataBound ="MyDataList_It emDataBound">
<ItemTemplate >
<TABLE id = "TableR">
<TR align="center">
<TD style="WIDTH: 18px; HEIGHT: 23px"><A href="Question. aspx?
questionId=1">1 .</A>
</TD>
<TD style="WIDTH: 149px; HEIGHT: 23px" bgcolor="#00fff f"><%#
DataBinder.Eval (Container.Data Item, "studentAnswer1 ")%>
</TD>
</TABLE>
</asp:datalist>
I hope my explanation is understandable. If not, just ask n I will clarify
further.
TIA.
Andrew.

Nov 19 '05 #3

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

Similar topics

1
4568
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
10
2855
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...
6
2189
by: tshad | last post by:
I need to get to a status label I have on my footer section of my datalist. There is no event happening that would go to the footer. I am just doing some processing and want to update the label on the footer. At the moment, I go through the dataListItems like so: for each oItem as DataListItem in DataList1.Items trace.warn("inside for loop oItem type = " & oItem.itemType.ToString())
4
4041
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
3442
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: //Page_load of my user control protected void Page_Load(object sender, EventArgs e) { IDataItemContainer DataContainer = this.Parent as
1
3961
by: shantanu_kush | last post by:
Hi there, I am using a DataList in a composite control. The DataList has an Custom ItemTemplate(ITemplate) which adds a Button to the DataList Item as shown in the code below : public class DatalistItemTemplate : ITemplate { public void InstantiateIn(Control container)
1
3908
by: Jim in Arizona | last post by:
I'm don't know how I would get around this. When working with a datalist control, there a specific built in commands (OnEditCommand, OnCancelCommand, etc). These commands, when the datalist control is made, refer to a subprocedure (eg: OnUpdateCommand="MyUpdateProcedure"). When referring to a specific record that's written to the page by the datalist object, it refers to the datakey (eg: <asp:datalist datakeyfield="ID" ...>). Then...
6
2223
by: Victor | last post by:
Hi. all I have a customize web control. I have three simple properties and customized render class. then I add this control into my datalist like <asp:DataList ID="datalist" runat="server" RepeatColumns="3"> <ItemTemplate> <uc:mycontrol id="test" runat="server" /> </ItemTemplate> </asp:DataList> In the code-behind I have something like List<mycontrol lst = new List<mycontrol >;
3
2810
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I need to control the visibility of a textbox based on a dropdown selection in the datalist's edititem template. To do this, I registered a client script block function and attached a client side handler for the dropdownlist's onchange event in the...
4
3985
by: Peter | last post by:
I have a DataList and each item in the datalist has an imge, I want to change the datalist item image on the client side when user clicks a button. How would I do that with JavaScript, does anyone has an example of how to change a DataList item with JavaScript? Thank You Peter
0
8996
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9566
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
9388
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
9333
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
4608
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...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2217
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.