473,386 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to insert a dropdownlist sourced by a dB inside a datalist row

Good Morning,
In my web page I've a datalist that is sourced by a database,
the problem is that I want that one of the column of the datalist contain a
dropdownbox
that also is sourced by a table in the database.

<asp:DropDownList id="ComboTipoPartita" runat="server"
DataValueField="IDTipoPartita"
DataTextField="DescrizioneTipoPartita"
DataSource="<% BindComboTipoPartita() %>"
</asp:DropDownList>


this seems impossible in aspx c# , the error tells :

" 'DataSource' property could be set just at runtime and cannot be declared
"

I'm interested to solve my problem of insert a dropdownlist powered by a db
inside a row of the datalist,
how I can achieve this ??

Many thanks.

Eng. Antonio D'Ottavio
www.etantonio.it/en
Nov 22 '05 #1
2 1852
As the error suggests, set the DataSource in the run-time in the datalist
ItemDataBound event.

Eliyahu

"Antonio D'Ottavio" <po********@etantonio.it> wrote in message
news:ew*************@tk2msftngp13.phx.gbl...
Good Morning,
In my web page I've a datalist that is sourced by a database,
the problem is that I want that one of the column of the datalist contain a dropdownbox
that also is sourced by a table in the database.

<asp:DropDownList id="ComboTipoPartita" runat="server"
DataValueField="IDTipoPartita"
DataTextField="DescrizioneTipoPartita"
DataSource="<% BindComboTipoPartita() %>"
></asp:DropDownList>
this seems impossible in aspx c# , the error tells :

" 'DataSource' property could be set just at runtime and cannot be

declared "

I'm interested to solve my problem of insert a dropdownlist powered by a db inside a row of the datalist,
how I can achieve this ??

Many thanks.

Eng. Antonio D'Ottavio
www.etantonio.it/en

Nov 22 '05 #2
Thanks for your suggestion but I still have some problem
this is the error

System.NullReferenceException: Reference to an Object not setted on a
object instance

I have on the row numer 5 of the following function :

void BindComboTipoPartita(Object sender, DataListItemEventArgs e)
{
dsCampi.Tables.Add("TipoPartita");
OleDbDataAdapter daTipoPartita = new OleDbDataAdapter("SELECT
IDTipoPartita, DescrizioneTipoPartita from TipoPartita" ,OleDbconn);
daTipoPartita.Fill(dsCampi,"TipoPartita");
DropDownList ComboTipoPartita_DDL =
(DropDownList)e.Item.FindControl("ComboTipoPartita ");
ComboTipoPartita_DDL.DataSource=dsCampi.Tables["TipoPartita"];
ComboTipoPartita_DDL.DataBind();
}

and this is the datalist defined in the way you suggest :

<ASP:DataList id="MyDataCampi" runat="server" HorizontalAlign="Center"
RepeatDirection="Horizontal" RepeatColumns="1"
OnEditCommand="Edit_Command" OnUpdateCommand="Update_Command"
OnDeleteCommand="Delete_Command"
OnCancelCommand="Cancel_Command" OnItemDataBound="BindComboTipoPartita"
<HeaderTemplate>
<table width="100%" style="font: 8pt verdana">
</HeaderTemplate>

<ItemTemplate>
<tr style="background-color:CCFF99">
<td>
<asp:DropDownList id="ComboTipoPartita" runat="server"
DataValueField="IDTipoPartita"
DataTextField="DescrizioneTipoPartita"</asp:DropDownList> </td>
</tr>
</ItemTemplate>

<FooterTemplate>
</table>
</FooterTemplate>
</ASP:DataList>
Have you any idea to solve the problem ???
Thanks ....

Antonio D'Ottavio
www.etantonio.it/en


"Eliyahu Goldin" <re*************@monarchmed.com> ha scritto nel messaggio
news:eu**************@tk2msftngp13.phx.gbl... As the error suggests, set the DataSource in the run-time in the datalist
ItemDataBound event.

Eliyahu

"Antonio D'Ottavio" <po********@etantonio.it> wrote in message
news:ew*************@tk2msftngp13.phx.gbl...
Good Morning,
In my web page I've a datalist that is sourced by a database,
the problem is that I want that one of the column of the datalist
contain a
dropdownbox
that also is sourced by a table in the database.

<asp:DropDownList id="ComboTipoPartita" runat="server"
DataValueField="IDTipoPartita"
DataTextField="DescrizioneTipoPartita"
DataSource="<% BindComboTipoPartita() %>"
></asp:DropDownList>


this seems impossible in aspx c# , the error tells :

" 'DataSource' property could be set just at runtime and cannot be

declared
"

I'm interested to solve my problem of insert a dropdownlist powered by a

db
inside a row of the datalist,
how I can achieve this ??

Many thanks.

Eng. Antonio D'Ottavio
www.etantonio.it/en


Nov 22 '05 #3

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

Similar topics

0
by: rodneybauer1 | last post by:
hello: thanks in advance for any responses. i dont have a isp at home so have to use public library computer. will check this every couple days though. im using visual basic.Net windows XP with...
2
by: Antonio D'Ottavio | last post by:
Good Morning, In my web page I've a datalist that is sourced by a database, the problem is that I want that one of the column of the datalist contain a dropdownbox that also is sourced by a table...
0
by: Antonio D'Ottavio | last post by:
Good Morning, In my web page I've a datalist that is sourced by a database, the problem is that I want that one of the column of the datalist contain a dropdownbox that also is sourced by a table...
1
by: Antonio D'Ottavio | last post by:
Good morning, I've a problem with a dropdownlist located inside any row of a datalist, I fill both datalist and dropdownlist at runtime, the problem is with the dropdownlist infact using the event...
2
by: Ashish Sharma | last post by:
I have a DropDownList inside a DataList on a page. I want to set the selectedindex property of the DropDownList to some value. I bind the DropDownList on the ItemCreated Event of the DataList. ...
0
by: Ashish Sharma | last post by:
I have a drop down list inside a data list on a form like this : <asp:DataList ID="DataList1" runat="server" EnableViewState="False"> <ItemTemplate> <asp:Label ID="lblname" Runat="server"...
2
by: Shiju Poyilil | last post by:
Hi ! I have a requirement wherein i am binding a datalist which contains a label (Caption for the field) and some literal hidden fields and a dropdown list. When I am binding to the datalist.....
3
by: sling blade | last post by:
Hi, I have a dropdownlist in my DataList control and I am trying to set the SelectedItem property of the dropdownlist so when the datalist displays the user will see the text in the dropdownlist...
1
by: Joe Blanchard via .NET 247 | last post by:
Hello, Can someone please help me. I thought this would be simple but so far nothing I try works..... I've got a simple update page. On this page I have a datalist bound by data from a SQL...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...

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.