Gridview数据绑定未显示 [英] Gridview Data binding not displaying

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

问题描述

我知道这很简单,我必须忽略一些东西。我正在尝试单击按钮来绑定并显示我的gridview。我在代码上尝试了一些变体。无论是页面发布还是不回发,网格视图都不会在按钮单击上填充。如果我更改代码并在页面加载时填充它然后工作正常但一旦移动到按钮单击没有出现。



我已经尝试过并且没有发布帖子返回。



受保护的子Button1_Click(发送者为对象,e为EventArgs)处理Button1.Click 

If IsPostBack = False然后
gridview.DataSource = SqlDataSource1
gridview.DataBind()
结束如果

结束子





谢谢

解决方案

试试这个



 受保护的  Sub  Button1_Click(发件人 对象,e  As  EventArgs)句柄 Button1.Click 

如果 IsPostBack = True < span class =code-keyword>然后
gridview.DataSource = SqlDataSource1
gridview.DataBind()
结束 如果

结束 Sub


I know this is simple and I must be overlooking something. I'm trying on a button click to bind and display my gridview. I've tried a few variations on the code. Either the page posts back or it does not post back either way a gridview never populates on the button click. If I change the code and have it populate on page load then works fine but once moved to button click nothing appears.

I've tried with and with out the post back.

 Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    If IsPostBack = False Then
        gridview.DataSource = SqlDataSource1
        gridview.DataBind()
    End If

End Sub



thanks

解决方案

try this

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        If IsPostBack = True Then
            gridview.DataSource = SqlDataSource1
            gridview.DataBind()
        End If

    End Sub


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

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