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
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
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!
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.