Datalist DataSource Error

  • Thread starter Will Chamberlain
  • Start date
W

Will Chamberlain

I am currently converting some VB.NET web apps to C#. It has been pretty
seamless so far but have currently run into some problems that I can't
resolve. The line that generates the error is:

The specific error is:

CS1502: The best overloaded method match for
'_Default.PopulateDrawingList(string)' has some invalid arguments

This is what is highlighted:

<asp:DataList ID="dlSheetType" cssclass="datalist1" DataSource='<%#
PopulateDrawingList(DataBinder.Eval(Container.DataItem,
"DrawingNumber")) %>' Runat="server">

The function referenced is:

public DataSet PopulateDrawingList(string DrawingNumber)
{
string strSQL = "SELECT Drawing, DCN, SheetNumber, SheetType, ADCN FROM
vwAllLatestrevSheetsWithADCN WHERE (Drawing = '" + DrawingNumber + "')
AND (State = 8) ORDER BY SheetType, SheetNumber, DCN, ADCN";

Dataset ds = new DataSet();
OleDbDataAdapter cm = new OleDbDataAdapter(strSQL, objConnSQL);
cm.Fill(ds, "DataTable");
ds.Tables["DataTable"].Columns.Add("NewADCN");
int dsRowCount = ds.Tables[0].Rows.Count;

for (int i=0; i <= dsRowCount; i++)
{
if (ds.Tables["DataTable"].Rows["ADCN"] is DBNull)
{ds.Tables["DataTable"].Rows["NewADCN"] = "&nbsp;";}
else
{ds.Tables["DataTable"].Rows["NewADCN"] =
ds.Tables["DataTable"].Rows["ADCN"];}
}
return ds.Tables[0];
}

Any suggestions as to where I can look to correct this problem?
 
W

Will Chamberlain

So I'm on the right track I believe. My error is now residing:
<asp:DataList ID="dlSheetType" cssclass="datalist1" DataSource='<%#
PopulateDrawingList(Container.DataItem("DrawingNumber")) %>'
Runat="server">

The exact error I get now is:
CS0118: 'System.Web.UI.WebControls.DataGridItem.DataItem' is a
'property' but is used like a 'method'

The source code:

DataSet ds = new DataSet();
OleDbDataAdapter cm = new OleDbDataAdapter(strSQL, objConnSQL);

cm.Fill(ds, "DataTable");
ds.Tables["DataTable"].Columns.Add("NewADCN");

int dsRowCount = ds.Tables[0].Rows.Count;

for (int i=0; i < dsRowCount; i++)
{
if (ds.Tables[0].Rows["ADCN"] is DBNull)
{ds.Tables[0].Rows["NewADCN"] =
Convert.ToInt32(ds.Tables[0].Rows["ADCN"]);}
else
{ds.Tables[0].Rows["NewADCN"] = "&nbsp;";}
}
return ds;

I am from a VB background and am seeing errors now that I have never
seen before. I am setting the function above as the datasource for a
datalist nested inside of a datagrid. When I do this in VB.NET it works
flawlessly. Any suggestions?
 
W

Will Chamberlain

Nevermind folks!

<%# PopulateDrawingList((string)DataBinder.Eval(Container.DataItem,
"DrawingNumber")) %>
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top