如何将数据库绑定到图像按钮 [英] how to bind database to the image button
问题描述
亲爱的先生,
如何从表格中获取id(seat _id)(table name = seatselection)并将该id绑定到image_Button ...
plz help ...
Dear sir,
how can i get the id(seat _id)from table (table name=seatselection)and bind that id to image_Button...
plz help...
推荐答案
在
Page_Load()
中,您可以从C#设置按钮的ID代码:
//从数据库表中加载你的id,然后
you can setup the ID of the button from the C# code:
//Load your id from your DB table, and then
image_Button.ID= id;
首先在你的应用程序中添加一个Image按钮,然后像这样传递Image的url:
First add a Image button to your application and pass the url of Image in it like this:
<asp:ImageButton Width="200px" Height="50px" ID="img" ImageUrl="~/Anubhav Chaudhary.jpg" runat="server" OnClick="img_Click" />
现在转到你的aspx.cs文件并点击这个图像按钮就像这样:
Now go to your aspx.cs file and writ on the click of this Image button like this:
protected void img_Click(object sender, ImageClickEventArgs e)
{
}
正如您在普通按钮上完成编码一样,此处也会进行类似的编码。首先添加SQL / Oracle / Access / Excel等命名空间,现在添加Connection,Command,Adaptar,reader或任何你需要的东西,只需点击这个Image按钮即可提供编码。
As you had done the coding on normal button, similar coding will be done here also. Firstly add Namespace for SQL/Oracle/Access/Excel etc. now add the Connection, Command, Adaptar, reader or whatever you need and just provide the coding in the click of this Image button.
这篇关于如何将数据库绑定到图像按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!