0

How to retrieve value from sqldatasource1 to textbox1 using vb.net ?

i have a table with field Employee Id : 1001

I wannna retrive the top1 employee id in textbox1 using sqldatasource1

2
  • We are going to need to see code, what is sqldatasource1? Commented Dec 1, 2010 at 16:05
  • It is asp.net SqlDataSource Control you find in Data Tab of Visual Studio 2008 Commented Dec 1, 2010 at 16:07

2 Answers 2

1

Something like this may help:

DataView oDataView = new DataView();
oDataView = SqlDataSource1.Select(DataSourceSelectArguments.Empty);
DataRowView dr = oDataView[0];
TextBox1.Text = dr["EmployeeID"].ToString();

I have not tested this code though.

You may also want to read the followings to get more info on SQLDataSource:

http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/sqldatasource.aspx http://www.aspfree.com/c/a/ASP.NET/Programming-the-ASPNET-20-SqlDataSource-Control/ http://www.defaultdotaspx.com/Answer.aspx?QuestionType=ASPNET&QuestionID=149 http://www.mikesdotnetting.com/Article/64/Bind-Data-From-a-SqlDataSource-to-a-Label

Hope this helps!

Sign up to request clarification or add additional context in comments.

1 Comment

You can use any online converter to get the VB.NET version of this sample code such as converter.telerik.com.
0

The easiest way is to call the data source's Select() method, pass in the arguments, and the results are returned as an IENumerable.

Otherwise, the only way is put the textbox in a FormView control, and specify the value to bind via Text='<%# Eval("Field") %>' /> and specify the DataSourceID of the form view.

HTH.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.