2011-05-07 75 views
0

我有一个项目,我在其中管理界面。在管理界面我必须做以下工作。如何在数据列表控件中显示数据库中的数据

  • 允许用户选择在 他要执行 动作(delte,显示更新)表。

  • 保存用户信息。我是 保存图像路径。我也必须 也是这样一个用户图像管理 接口就userid。

问题是我有保存图像路径。我必须在数据列表控制中显示图像。任何人都可以建议我如何执行这项任务?我必须通过源代码使用数据列表。

回答

0

那么,如果我理解你corectly你想要一个下拉的图像,据我所知,是不可能的。 你可以做的是建立一个数据绑定下拉列表,并与图像控制研究,这将显示在下拉列表中选择的图像,因为这样的:

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; 

,那么你可以更新ImageUrl属性OnIndexChanged。

祝你好运, Michael

相关问题