How to show data from database in Data List Control
I have a project in which I am working on admin interface . In admin interface I have to do following work.
Allow user to select table in which he want to perform action(delte,show,update).
While saving user information. i am saving the image path. and i h开发者_JS百科ave to also so a user image in admin interface in respect to userid.
The problem is that I have save image path. and i have to show image in data list control. Can any one suggest how can I perform this task? I have to use data list through source code.
Well, if I understand you corectly you want a dropdown of images which is, to the best of my knowledge, impossible. What you could do is create a databound drop-down and and image controll which will display the image selected in the dropdown, as such:
SqlDataSource yourDataSource = new SqlDataSource("your connection string here", "select command here. Something like 'SELECT id, image FROM table'");
DropDownList yourDropDown = new DropDownList();
yourDropDown.DataSource = yourDataSource;
// makes the dropdown show the id but the value will return the image value
yourDropDown.DataTextField = "id";
yourDropDown.DataValueField = "image";
yourDropDown.DataBind();
Image img = new Image();
img.ImageUrl = yourDropDown.SelectedValue;
then you could update the ImageURL property OnIndexChanged.
Best of luck, Michael
精彩评论