Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get data from Select tag and Insert into Input tag using ASP.NET

Tags:

html

c#

sql

asp.net

Right now I have a Select Tag retrieving all the Title of the documents from the Database:

string QueryString = "SELECT TITLE FROM DOC";
SqlConnection myconnection = new SqlConnection(ConnectString);
SqlDataAdapter mycommand = new SqlDataAdapter(QueryString,myconnection);
DataSet ds = new DataSet();
mycommand.Fill(ds, "DOC");

test.DataSource = ds;
test.DataTextField = "TITLE";
test.DataValueField = "TITLE";
test.DataBind();

The problem is that I need to store all this data in text so that I can use the MailMessage Class and send it via Email.

Any Thoughts?

like image 363
Pvxtotal Avatar asked Dec 28 '25 22:12

Pvxtotal


1 Answers

You can convert DataSet to list

var titleList = ds.Tables[0].AsEnumerable()
.Select(dr => new {Name = dr.Field<string>("TITLE")}).ToList();

Then you can concatenate it into single string:

var titles = titleList.Aggregate((current, next) => current + ", " + next);
like image 116
Eugene Avatar answered Dec 30 '25 12:12

Eugene



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!