简体   繁体   中英

How to populate aspx:TextBox with SqlDataSource as we can in aspx:DropDown?

I need to populate a text box using some queries. I an newbie in asp.net, whereas i was able to do that with asp:DropDown . How should i do that?

You need to use the Page.DataBind() to bind public properties with your page.

<asp:textbox id=txt text="<%# custID %>" runat=server />

Refer the databinding overview

ASP.NET introduces a new declarative syntax, <%# %>. This syntax is the basis for using data binding in an .aspx page. All data binding expressions must be contained within these characters.

No data is rendered to the control until you explicitly call either the DataBind method of the Web server control or until you invoke the page-level Page.DataBind method. Typically, Page.DataBind (or DataBind) is called from the Page_Load event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM