471,122 Members | 890 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How to ... Dropdownlist sourced by a DB inside a datalist ??

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.

The problem is is the error :

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

It is on the istruction
"ComboTipoPartita_DDL.DataSource=dsCampi.Table s["TipoPartita"];" 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 I defined :

<ASP:DataList id="MyDataCampi" runat="server" ...
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

Sep 16 '05 #1
0 1172

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Ashish Sharma | last post: by
reply views Thread by Ashish Sharma | last post: by
2 posts views Thread by Shiju Poyilil | last post: by
1 post views Thread by Joe Blanchard via .NET 247 | last post: by
1 post views Thread by Antonio D'Ottavio | last post: by

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.