I have used a SqlDataAdpter to fill a DataSet which is then bound to a
Repeater. Works great. The DataSet contains a table of blocks of text from
many web
applications, this web application checks the spelling of all of the text.
As the spell checking application checks words, the DataSet is updated with
any corrected words. So at the end of the spell checking the DataSet no
longer contains just the original text blocks. I have now found out that the
SqlDataAdapter.UpdateCommand will not work - the data adapter must have the
original DataSet. I have constructed my SqlUpdateCommand with my own UPDATE
statements, parameters, etc.
When I try to run the UpdateCommand on the SqlDataAdapter, an exception is
raised stating that I have not used the SELECT command on the DataAdapter -
the DataAdapter from the initial SELECT was Disposed so I created a new one.
So, if my Sql method that originally created the DataAdapter and DataSet
returned the DataAdpater instead of the DataSet, is there still an active
connection to Sql Server?
If the connection is closed, will it work if I maintain the state of the
DataAdapter (and so the DataSet it filled), and thus use the .UpdateCommand
in the end?
Is there a better way to do this without recreating the original DataSet at
the end and merging the original and updated?
Thank you again for your time.
**************************
Lateralus said:
I figured that since you know how to expose your arraylist, you can expose
your dataset and/or dataview through a public property.
protected DataSet _dataSet = null;
public DataSet MyDataSet
{
get{return(this._dataSet);}
set{this._dataSet = value;}
}
public DataView MyView
{
get{return(this._dataSet.Tables[0].DefaultView);}
}
--
Lateralus [MCAD]
ASP Yaboh said:
The main reason is because I'm not familiar with Microsoft programming
languages and Visual Studio. I've been working in Java, Delphi and Pascal
and
a completely different architecture for some years. C# is no problem but I
find ASP.Net to be a completely different beast.
Lateralus said:
Is there any reason why you just don't expose the DataSet/DataView from
the
business object. As far as how to bind it, all you have to do is set the
datasource in the code behind to your DataSet/DataView/ArrayList and call
DataBind();
protected System.Web.UI.WebControls.Repeater myRepeater;
private void Page_Load(object sender, System.EventArgs e)
{
//your code to load your business object
this.myRepeater.DataSource = put your array list object here;
this.myRepeater.DataBind();
}
--
Lateralus [MCAD]
I have one more question: How do I get to the data in the ArrayList?
What I have is an ArrayList (parent), where each field is another
ArrayList
(children). Each child holds a row returned from a recordset. The class
object has methods where an index (int), is passed in and the
corresponding
child data returned. For example, say each row contains a comment id,
comment
text and response text. Calling ".getComment(index)" where index = 5,
returns
the comment text from the fifth ArrayList or row.
Most of the examples I have found show Repeater with and XML file.
ArrayList
examples show the ArrayList as part of the .aspx file.
:
No problem. Glad to help.
--
Lateralus [MCAD]
I found by exposing the ArrayList(s) from the middle-tier objects,
the
aspx
page can bind the Repeater to it.
Thank you for your help.
:
1.) A Datagrid is a little simpler to use because it is basically a
single
table, with a row for every row in the list. A repeater is when you
need
to
customize the html a bit more. It sounds like you want a <table>
for
every
row in the array list. So it sounds like a repeater would suit you
better.
2.) I usually bind by repeaters/grids to a DataView. The DataSource
can
be
any System.Collections.IEnumerable derived object such as a
System.Data.DataView for accessing databases, an
System.Collections.ArrayList, a System.Collections.Hashtable, or an
array.
HTH
--
Lateralus [MCAD]
Two questions on that:
1. Do I need to use the DataGrid with the Repeater?
2. Binding to the data leaves me a little confused. The database
is
on
another tier and is only accessible through separate business
objects.
These
objects then expose the data where they might be held e.g. in
ArrayLists.
I
can not create a connection from the .aspx page directly to a
database
connection. Can I bind to other "objects"?
Again, thank you for your time.
:
I think you'll find that using Repeaters/DataGrids are much
cleaner
and
simpler than looping through the code manually. Plus it has
better
performance.
--
Lateralus [MCAD]
"Lateralus [MCAD]" <dnorm252_at_yahoo.com> wrote in message
Have you looked into using a repeater control?
--
Lateralus [MCAD]
message
I have an ArrayList of data gathered from a database. I want
to
create
a
web
page from this data by creating a <table>, each cell in each
row
displays
the
appropriate data. One of those cells in each row needs a
<textarea>
control.
The background supporting classes are completed, the only
task
left
now
is
to create the web page. I am at a loss on how to create the
table
in
the
page
populated by the data. Previously, I would have just iterated
through
the
data placing the data in the cells on the HTML page by <%=
%>.
Any help would be appreciated.
Thank you.