IsPostBack好像没作用
如何写客户端?

解决方案 »

  1.   

    用C#写的我会,用VB.NET的不会,在按钮的事件最后加上一句,重定向到这一ASPX,就OK了
    C#中是这一句
    Response.Redirect(Request.Url);
    我会看VB.NET,但不会写,SORRY
    VB.NET做同样的事,要敲的代码比C#多好多,在文档支持上也不如C#,学C#的多过VB的好多倍,所以学C#,至少找解决方法也方便多了
      

  2.   

    你要是想用存储过程就到数据库里写,在页面中直接调用不是更好些吗?
    我用的也是VB,刷新页面onclick事件是不会执行。
    我帮你写一个,你试试看.
    假设你存储过程是在数据库里写好的。名为"sp_addcart" 
    objcon 为sqlconnectionPrivate Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        if not ispostback then
              bin()
        end if
    End Subsub bin()
        dim dad as new sqldataadapter(""select * from card",objcon)
        dim ds as new dataset()
        dad.fill(ds,"cart")
        DataGrid1.DataSource = Ds.Tables("card").DefaultView
        DataGrid1.DataBind()
        objcon.close()
    end subSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
           dim cmd as new sqlcommand("sp_addcart",objcon)
           cmd.commandtype=commandtype.storedprocedure
           cmd.parameters.add("@name",Textbox1.Text)
           cmd.parameters.add("@sex",Textbox3.Text)
           cmd.parameters.add("@phone",Textbox4.Text)
           cmd.parameters.add("@add",Textbox2.Text)
           objcon.open()
           cmd.executenonquery()
           objcon.close()
           bin()
      End Sub有问题发信息给我。
      

  3.   

    你每刷新一次 OleDA.Fill(Ds, "card") 就被填一次加上IsPostBack试试Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            bin()
        End Sub    Sub bin()
            
            OleDA.SelectCommand.CommandText = "select * from card"
            OleDA.Fill(Ds, "card")
            DataGrid1.DataSource = Ds.Tables("card").DefaultView
            DataGrid1.DataBind()
        End Sub
      

  4.   

    肯定要加在if IsPostBack() then
    dend if中才行,你放在page_load当然刷一次页面绑定一次了。
    建一个绑定函数binddata(),在里面将数据绑定好,在if ispostback() then中调用可以了
    其它地方要绑定调这个函数就可以了。
      

  5.   

    to ajqc(ajqc)
    vb.net也是这样写的Response.Redirect(Request.Url)
    用这样的方法解决了..