FineUI 官方论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

本论坛已关闭(禁止注册、发帖和回复)
请移步 三石和他的朋友们

FineUI首页 WebForms - MVC & Core - JavaScript 常见问题 - QQ群 - 十周年征文活动

FineUI(开源版) 下载源代码 - 下载空项目 - 获取ExtJS - 文档 在线示例 - 版本更新 - 捐赠作者 - 教程

升级到 ASP.NET Core 3.1,快、快、快! 全新ASP.NET Core,比WebForms还简单! 欢迎加入【三石和他的朋友们】(基础版下载)

搜索
查看: 2966|回复: 7
打印 上一主题 下一主题

grid绑定问题

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-25 10:18:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
当grid的window列更新数据后关闭window,刷新父窗体的grid,发现只能绑定BoundField的参数,TemplateField的参数则无法绑定,显示空白
沙发
发表于 2012-12-25 11:35:00 | 只看该作者
先调试一下呢
板凳
 楼主| 发表于 2012-12-26 01:18:42 | 只看该作者
断点跳进去了,但是还是不能显示,只能通过刷新整个页面显示,这样不好
地板
发表于 2012-12-26 05:33:49 | 只看该作者
可以先自己调试下,应该是自己的代码问题,实在不行的话给个能运行的示例。。。
5#
 楼主| 发表于 2012-12-26 06:53:03 | 只看该作者
写了一个demo实例,三石大哥看看,这个是父页面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default16.aspx.cs" Inherits="Default16" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <extageManager ID="ageManager1" runat="server" />
        <ext:Grid ID="Grid1" runat="server" EnableCheckBoxSelect="true" EnableRowNumber="true"
            Title="Grid" OnRowDataBound="Grid1_DB" Height="200px">
            <Columns>
                <ext:BoundField HeaderText="头部1" DataField="col1" />
                <ext:BoundField HeaderText="头部2" DataField="col2" />
                <ext:TemplateField>
                    <ItemTemplate>
                        <extabel runat="server" ID="col3"></extabel>
                    </ItemTemplate>
                </ext:TemplateField>
                <ext:WindowField ColumnID="WinEdit" WindowID="Window1" HeaderText="编辑" Icon="Add"
                        ToolTip="编辑" DataIFrameUrlFormatString="window.aspx"
                         />
            </Columns>
        </ext:Grid>
        <ext:Window ID="Window1" Title="编辑" Popup="false" EnableIFrame="true" runat="server"
        CloseAction="HidePostBack" EnableConfirmOnClose="true" IFrameUrl="window.aspx"
        EnableMaximize="true" EnableResize="true"  Target="Top"
        IsModal="True" Width="760px" Height="500px" OnClose="Window1_Close">
    </ext:Window>
    </div>
    </form>
</body>
</html>

这个是父页面的代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FineUI;

public partial class Default16 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bind();
        }
    }

    private void bind()
    {
        Grid1.DataSource = createtestcls();
        Grid1.DataBind();
    }

    protected void Grid1_DB(object sender, GridRowEventArgs e)
    {
        testcls tt= e.DataItem as testcls;
        FineUI.Label ll = Grid1.Rows[e.RowIndex].FindControl("col3") as FineUI.Label;
        ll.Text = tt.col3;
    }

    private List<testcls> createtestcls()
    {
        List<testcls> List = new List<testcls>();
        for (int i = 0; i < 3; i++)
        {
            testcls t = new testcls();
            t.col1 = i.ToString();
            t.col2 = i.ToString() + i.ToString();
            t.col3 = i.ToString() + i.ToString()+t.ToString();
            List.Add(t);
        }
        return List;
    }

    protected void Window1_Close(object sender, EventArgs e)
    {
        bind();
    }
}


public class testcls
{

    public string col1 { get; set; }
    public string col2 { get; set; }
    public string col3 { get; set; }
}

这个是弹出页面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="window.aspx.cs" Inherits="window" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <extageManager ID="ageManager1" runat="server" AutoSizePanelID="anelForm" />
        <extanel ID="anelForm" runat="server" EnableBackgroundColor="true" Layout="Row">
            <Items>
        <ext:Button ID="Button1" runat="server" Text="Button">
        </ext:Button>
            </Items>
        </extanel>

   
    </form>
</body>
</html>


这个是弹出页面的后台代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FineUI;

public partial class window : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Button1.OnClientClick = ActiveWindow.GetConfirmHidePostBackReference();
    }

}
弹出页面点击按钮关闭后,父窗体的templete里的字段没有绑定啊,求指导
6#
发表于 2012-12-26 06:57:13 | 只看该作者
TemplateField 中目前只能放 Asp.Net 控件
7#
 楼主| 发表于 2012-12-26 07:09:13 | 只看该作者
哦,原来如此,谢谢三石,没注意到这个{:soso_e113:}
8#
发表于 2012-12-27 02:13:24 | 只看该作者
sanshi 发表于 2012-12-26 05:33
可以先自己调试下,应该是自己的代码问题,实在不行的话给个能运行的示例。。。 ...

为什么我在grid重新添加一项,然后不刷新页面,再点击编辑就报X1错误,困扰很久了 求解答
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|FineUI 官方论坛 ( 皖ICP备2021006167号-1 )

GMT+8, 2024-9-20 01:17 , Processed in 0.045789 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表