473,545 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bind listbox inside Bound datalist

In the code below, I have an editItemTemplat e that will have to have a
long list of ip's bound to it. The problem is that the lisbox is not
seen by asp.net until after the datalist containing it is exposed.

Is there a way to bind the ddl inside of an already databound
templated column?

Thanks , of course

Michael

void Page_Load ( Object src, EventArgs e ) {
if ( !IsPostBack ) {
// fetch and store data into Session
string query = "Select * from desktops";
Session [ "myTable" ] = ( fetchData ( query, "portchart" )
).Tables [ 0 ];
bindList ( );
}
}
void myListEditHandl er ( Object src, DataListCommand EventArgs e
) {
myList.EditItem Index = e.Item.ItemInde x;
bindList ( );
// clear optional message
msg.Text = "";
}

void myListCancelHan dler ( Object src, DataListCommand EventArgs
e ) {
myList.EditItem Index = -1;
bindList ( );
}

void myListUpdateHan dler ( Object src, DataListCommand EventArgs
e ) {
// e.Item represents the current row in edit mode ...
// get updated row values
string ip = ( ( TextBox ) e.Item.FindCont rol ( "ip" ) ).Text;
string node = ( ( TextBox ) e.Item.FindCont rol ( "node" )
).Text;
string location = ( ( TextBox ) e.Item.FindCont rol (
"location" ) ).Text;
string term = ( ( TextBox ) e.Item.FindCont rol ( "term_id" )
).Text;
string mon = ( ( TextBox ) e.Item.FindCont rol ( "MON_TAG" )
).Text;

// load data from Session
DataTable myTable = ( DataTable ) Session [ "myTable" ];

// get and update row
DataRow myRow = myTable.Rows [ e.Item.ItemInde x ];
myRow [ "ip_addr" ] = ip;
myRow [ "node" ] = node;
myRow [ "location" ] = location;
myRow [ "term_id" ] = term;
myRow [ "MON_TAG" ] = mon;
myTable.AcceptC hanges ( );

// refresh data in Session
Session [ "myTable" ] = myTable;

// set edit mode off
myList.EditItem Index = -1;
bindList ( );

// optional message
msg.Text = "Data for <b>" +
( ( Label ) e.Item.FindCont rol ( "nodelbl" ) ).Text +
"</b> updated";
}

void bindList ( ) {
// bind list to current data in Session
myList.DataSour ce = Session [ "myTable" ];
string query = "Select ip_addr from ips where in_use =0";
myList.DataBind ();

}
</script>
</head>

<body>

<div class="header"> <h3>PortChart </h3></div>

<hr size=1 width=90%>

<div align="center">
<form runat="server">
<%--asp:listbox id="lstFAQs" runat="server" Rows="1"
DataTextField=" ip_addr" DataValueField= "ip_addr" /--%>

<p><asp:label id="msg" runat="server" /></p>

<asp:datalist id="myList" runat="server"
width="75%"
cellpadding=5
repeatcolumns=1
backcolor="ghos twhite"
onEditCommand=" myListEditHandl er"
onUpdateCommand ="myListUpdateH andler"
onCancelCommand ="myListCancelH andler">

<headertemplate >
Port Chart
</headertemplate>

<headerstyle backcolor="dark slategray"
forecolor="khak i" font-bold />

<itemtemplate >
<asp:linkbutt on runat="server" commandname="ed it"
text='<%# ( ( DataRowView ) Container.DataI tem ) [ "node"
] %>' />
</itemtemplate>

<itemstyle font-size="8pt" verticalalign=" top" />

<edititemtempla te>

<table cellspacing=1 cellpadding=1 class="editor" width=100%
align="center">
<tr>
<th colspan=2><asp: label id="nodelbl" runat="server"
text='<%# ( ( DataRowView ) Container.DataI tem ) [
"node" ] %>' /></th>
</tr>
<tr>
<td>Ip Address </td>
<td>
<asp:listbox id="lstFAQs" runat="server" Rows="1"
DataTextField=" ip_addr" DataValueField= "ip_addr" />
</td>
</tr>
<tr>
<td>Node Name </td>
<td><asp:textbo x id="node" runat="server"
text='<%# ( ( DataRowView ) Container.DataI tem ) [
"node" ] %>' /></td>
</tr>
<tr>
<td>User Name: </td>
<td><asp:textbo x id="location" runat="server"
text='<%# ( ( DataRowView ) Container.DataI tem ) [
"location" ] %>' /></td>
</tr>
<tr>
<td>Terminal Id: </td>
<td><asp:textbo x id="term_id" runat="server"
text='<%# ( ( DataRowView ) Container.DataI tem ) [
"term_id" ] %>' /></td>
</tr>
<tr>
<td>Monitor Tag: </td>
<td><asp:textbo x id="MON_TAG" runat="server"
text='<%# ( ( DataRowView ) Container.DataI tem ) [
"MON_TAG" ] %>' /></td>
</tr>
<tr>
<td>Cpu Tag: </td>
<td><asp:textbo x id="CPU_TAG" runat="server"
text='<%# ( ( DataRowView ) Container.DataI tem ) [
"CPU_TAG" ] %>' /></td>
</tr>
<tr>
<td>Comments: </td>
<td><asp:textbo x id="COMMENTS" runat="server" rows=5
textmode="multi line"
text='<%# ( ( DataRowView ) Container.DataI tem ) [
"COMMENTS" ] %>' /></td>
</tr>
<tr align="center">
<td colspan=2>
<asp:linkbutt on commandname="up date" runat="server"
text="Update" />
<asp:linkbutt on commandname="ca ncel" runat="server"
text="Cancel" />
</td>
</tr>
</table>

</edititemtemplat e>

</asp:datalist>

</form>
</div>
<hr size=1 width=90%>
</body>
</html>
Nov 18 '05 #1
0 1914

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

Similar topics

4
2258
by: Moojjoo | last post by:
Ok fellow C# developers: How do creat an instance of an object inside a dataset or datagrid. Example I need to have a placeholder inside a dataset. Any help would be great.
3
3780
by: Dmitry Korolyov [MVP] | last post by:
Is that possible? In other words, I want a dropdown list (and other list-type controls) which appears in edit more of a templated column to be populated with data at the run time. An attempt to do so results in non-existing object error. (Object reference not set to an instance of an object). -- Dmitry Korolyov MVP: Windows Server - Active...
0
1280
by: Beorn | last post by:
Does anybody have experience using a bound ListBox within a DataList? The DataList should repeat for a list of Categories, each category holds a list of components under that category. The User wil select a component for each category (with an associated price....) and click update, the adjusted price (sum of all selelcted components) is...
1
2308
by: Bigtoga | last post by:
Okay - I'm going crazy here trying to figure out how to do this - here goes: I have a DataList populated by a DataReader. In the DataReader, a column is present called "IsInCategory". I want to have a checkbox bound to that column (bit in SQL Server). I have tried everything and can't see a way to do this without createing an event...
0
1249
by: Steve | last post by:
Hi, I have a problem here with bounding data inside a datalist. Currently I am working on a page which I can have a list of items using a datalist(listA). Inside this datalist(listA) i would like to bound with another datalist(listB) so I am able to list items in listB based on the unique value on listA. here's the code that I kinda...
18
1999
by: Dave Sauny | last post by:
Ok, its a friday, I'm at work and I cant get this to work: I have 3 listboxes on one tab control page. when i select an item in listbox1 i want whatever is selected on the other 2 listboxes unselected. when listbox2 is selected, 1 and 3 should have no items selected and the same with listbox 3. Sounds simple... should be simple! I have...
1
2182
by: Mike | last post by:
I have a Datalist control on my page that I have binded to a table of available categories. In the Item Template I have a CheckboxList control bound to the products available in each Category. I need to pull out of the page which products the user has selected. I have bound the products to the CheckboxList control in the ItemDataBound...
2
3402
by: Phil | last post by:
I have a datalist (DataList1)... with an itemtemplate... then a table - server side (Table1)... then another datalist (DataList2)... another itemtemplate... another table - server side (Table2) DataList1 is bound to an objectdatasource (ObjectDataSource1), and has a datakey (CategoryId). I want to bind DataList2 to another...
2
2045
by: ASP Developer | last post by:
Is it possible to bind a datalist that is inside of a bound datalist? Any help would be greatly appreciated.
0
7457
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...
1
7410
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...
0
7746
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5320
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...
0
4941
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...
0
3443
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...
0
3438
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1869
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
1
1010
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.