在imagebutton上填充gridview单击 [英] Populate a gridview on imagebutton click

查看:43
本文介绍了在imagebutton上填充gridview单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我希望单击图像或图像按钮时,我的页面应重定向到包含网格视图的另一个页面.假设图像ID为Supplier1,并且单击此图像,我想在网格视图中显示Supplier1的详细信息,例如他所购买的产品和奖品等.我已经使用了objectdatasource连接到网格视图并通过应用我成功地填充了网格视图的联接,但是我找不到与图像建立的链接.您的答复将不胜感激.在此先感谢您

Hi all,
i want that on the click of an image or an image button my page should get redirected to another page which comprise of a grid view. Suppose that image id is supplier1 and on the click of this image i want to show the details of supplier1 in the grid view eg the products he paid for and the prize etc. i have used an objectdatasource to connect to the grid view and by applying a join i have succeeded in populating the grid view but i am unable to find a link to establish with the image. your reply will be appreciated.Thank you in advance

推荐答案

您可以简单地在背景图片中使用超链接.在网址的查询字符串中包含供应商ID.单击链接将转到新页面,并根据ID将详细信息加载到gridview中.这有意义吗?

谢谢
Mahmud
You can simply use a hyperlink with the image in background. Have the supplier id in the querystring of the url. Clicking on the link you will go to the new page and based on the id you will load the detail in the gridview. Does this make sense?

Thanks
Mahmud


尝试将查询值加载到数据源和gridview中

昏暗conn作为新的MySqlConnection
将myCommand调暗为新的MySqlCommand
昏暗的daMySQL作为MySqlDataAdapter''Novo
昏暗的dsMySQL作为数据集''Novo
Dim SQL As String

Dim Conectaprovide作为新的Conectar
昏暗的oconecta作为新的Conectar''

oconecta.AbreBanco(conn)

SQL ="SELECT DISTINCT Mensagem" + _
"FROM Home_Mensagem_meio" + _
按ID DESC排序"
试试
myCommand.Connection = conn
myCommand.CommandText = SQL
试试
daMySQL =新的MySqlDataAdapter(SQL,conn)
dsMySQL =新数据集
daMySQL.Fill(dsMySQL,"mensagem")
gvCategorias.DataSource = dsMySQL
gvCategorias.DataBind()
将Myerro捕获为MySqlException
结束尝试
conn.Close()
将Myerro捕获为MySqlException
终于
conn.Dispose()
结束尝试



try loading the query values ​​in a datasource and a gridview

Dim conn As New MySqlConnection
Dim myCommand As New MySqlCommand
Dim daMySQL As MySqlDataAdapter ''Novo
Dim dsMySQL As DataSet ''Novo
Dim SQL As String

Dim Conectaprovide As New Conectar
Dim oconecta As New Conectar ''

oconecta.AbreBanco(conn)

SQL = "SELECT DISTINCT Mensagem " + _
"FROM Home_Mensagem_meio " + _
"ORDER BY Id DESC"
Try
myCommand.Connection = conn
myCommand.CommandText = SQL
Try
daMySQL = New MySqlDataAdapter(SQL, conn)
dsMySQL = New DataSet
daMySQL.Fill(dsMySQL, "mensagem")
gvCategorias.DataSource = dsMySQL
gvCategorias.DataBind()
Catch myerro As MySqlException
End Try
conn.Close()
Catch myerro As MySqlException
Finally
conn.Dispose()
End Try



then you need to recover through the databind the option
  <,% # Eval ("link"%)>





<pre lang="xml">&lt;asp:GridView ID=&quot;gvCategorias&quot; runat=&quot;server&quot; AutoGenerateColumns=&quot;False&quot;
        Height=&quot;123px&quot; Width=&quot;146px&quot;&gt;
    &lt;Columns&gt;
        &lt;asp:TemplateField&gt;
            &lt;ItemTemplate&gt;
                &lt;asp:HyperLink ID=&quot;linkCategoria&quot; runat=&quot;server&quot;
                    NavigateUrl=&#39;&lt;%#&quot;?id_cat=&quot; + Eval(&quot;id&quot;)%&gt;&#39;&gt;&lt;%# Eval(&quot;name&quot;) %&gt;&lt;/asp:HyperLink&gt;
            &lt;/ItemTemplate&gt;
            &lt;HeaderTemplate&gt;
                Categorias
            &lt;/HeaderTemplate&gt;
        &lt;/asp:TemplateField&gt;
    &lt;/Columns&gt;
&lt;/asp:GridView&gt;</pre>


这篇关于在imagebutton上填充gridview单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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