如何将数据绑定到图像 [英] how to bind data to images

查看:64
本文介绍了如何将数据绑定到图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个学生图像,这些图像在我的网站上滚动。

我在数据库中有一个学生表。现在,当我点击我网站上的特定学生图像时,它会显示来自学生表的特定学生的详细信息。

解决方案

这是一个非常多的数据库工作,用于查询有关学生的数据。你要做的是为学生创建一个表格,其中包含有关他的所有信息,包括他的照片。表格可以是这样的,



 StudentID |名称| FatherName |图片|课程[|其他栏目......] 
1 |艾哈迈德|阿卜杜拉| Pic.png | ..剩余数据





..现在您的网站上有一些图片,(正如您所说)可以查看(因为您滚动说;我假设您的意思是用户可以滚动查看网站中的所有图像)并且图像有一个名称(如果它有ID,则更好)。您可以为这些图像创建超链接,以指向学生的个人资料页面。像这样,



 <! -     ASP.NET版本的代码,将其更改为您的语言   - >   
< a href = 〜/ profile / @学生.StudentID >
<! - 显示图片... - >
< img src = 〜/ images / @Student.Picture alt = 学生图片 / > ;
< / a >





..现在,一旦用户点击,他将被重定向到个人资料页面,然后将是URL末尾的学生ID。在该页面上,您可以使用该StudentID查询数据库,并获取与他相关的所有数据。



提示:始终尝试制作单个数据表尽可能多的尝试。不要复制表中的数据,而是将每个对象(Student是一个对象)的数据保存在同一个表中,而不是为他所拥有的每个属性(Name,FatherName,Picture,Course等)创建不同的表。 )。


i have multiple images of students and those are scrolling in my website.
And i have a students table in database.Now, when i click on a particular student image in my website it will display the details of particular Student from students table.

解决方案

That is a pretty much database job, to query the data about the Student. What you would do, is to create a table for a Student that will contain all of the information about him, including his picture. The table can be like this,

StudentID | Name | FatherName | Picture | Course [| other columns...]
1         | Ahmad| Abdullah   | Pic.png | .. remaining data 



.. now there are some images in your website, which (as you say) can be viewed (because you said scrolling; I assume you meant that the user can scroll to see all of the images in the website) and the image has a name (or better if it has an ID). You can create a hyperlink for those images, to direct to the profile page for the student. Like this,

<!-- ASP.NET version of code, change it to your language -->
<a href="~/profile/@Student.StudentID">
   <!-- Show the image... -->
   <img src="~/Images/@Student.Picture" alt="Student Picture" />
</a>



.. now once the user will click, he will be redirected to the Profile page, and there will be the student's ID assosiated at the end of the URL. On that page you can use that StudentID to query the database, and get all of the data assosiated to him.

Tip: Always try to make a single table as much as you can try. Do not duplicate the data inside the tables, but save the data for every object (Student is an object) inside the same table, instead of creating a different table for each of the attribute he is having (Name, FatherName, Picture, Course etc).


这篇关于如何将数据绑定到图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆