ArrayList/DropDownList in DataGrid

G

Guest

Hi

I'm trying to have a dropdownlist inside a datagrid which
I can do visually but for some reason my data is not being
displayed in the dropdownlist.

My html is:
<asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT:
339px; POSITION: absolute; TOP: 167px"
runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="TASK_NAME"
HeaderText="Task"></asp:BoundColumn>
<asp:BoundColumn DataField="PROJECT_NAME"
HeaderText="Project"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Language">
<ItemTemplate>
<asp:DropDownList ID="LangDropDownList"
DataTextField="LANG_NAME" DataValueField="LANG_NAME"
Width="120px" Runat="server" DataSource='<%# GetLanguages
((System.Data.DataRowView) Container.DataItem) %>' />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

I think this is ok since it displays things find but I'm
assuming that I don't have to call my GetLanguages method
anywhere - is that correct?

In my C# code I have:
protected System.Web.UI.WebControls.DataGrid DataGrid1;

private void Page_Load(object sender, System.EventArgs e)
{
if ( !IsPostBack )
{
Webtest.TaskDB taskDetails = new Webtest.TaskDB();
Webtest.TaskDB tasks=new Webtest.TaskDB();
DataSet ds=new DataSet();

OleDbDataAdapter oda=taskDetails.GetTaskDetails();
OleDbDataAdapter lda=tasks.GetTasks();

oda.Fill(ds,"LanguageTable");
lda.Fill(ds,"TaskTable");

DataColumn dc1=ds.Tables["TaskTable"].Columns["TASK_NAME"];
DataColumn dc2=ds.Tables["LanguageTable"].Columns
["TASK_NAME"];
DataRelation drel=new DataRelation
("TaskandLanguages",dc1,dc2);
ds.Relations.Add(drel);

DataGrid1.DataSource=ds;
DataGrid1.DataBind();
}
}

public ArrayList GetLanguages(DataRowView drv)
{
DataRow dr=drv.Row;
DataRow[] adr=dr.GetChildRows("TaskandLanguages");

ArrayList a=new ArrayList();
foreach(DataRow tmp in adr)
a.Add(tmp["langdesc"]);

return a;
}

I've double checked my database extraction stuff elsewhere
and that seems fine so everything that I need is coming
from the database. Have I set the relation drel up ok?

What's happening is that I get none of the languages data
displayed(i.e the dropdownlist stuff).

Can anyone help?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,163
Latest member
Sasha15427
Top