2011-09-20 91 views
0

我有一个函数,它包含一个包含信息的字符串,将其拆分,然后将行和列添加到一个asp.net GridView。将数据绑定到事件中的数据网格

这很好,但问题是,这个功能是从一个触发的事件,然后当我这样做:

TestGrid.DataSource = (myTable).DefaultView; 
TestGrid.DataBind(); 

它不填写的网格和显示(为myTable拥有所有正确的信息)

我网的样子:

<asp:UpdatePanel ID="UpdateTestingGrid" runat="server" UpdateMode="Conditional"> 
       <ContentTemplate> 
        <asp:GridView ID="TestGrid" runat="server" CssClass="pipesTbl"> 

        </asp:GridView> 
       </ContentTemplate> 

如果我理解正确,这是有关的事情,这是不正常的,

任何人可以尝试和帮助吗? 甚至只是帮助我和谁开始搜索谷歌?我在找什么?

编辑

希望这有助于有点

protected void progressBar_RunTask(object sender, EO.Web.ProgressTaskEventArgs e) 
{  
    tester.done += new tester.PipeDoneEvtArgs(tester_Done); 

    progressBar.Maximum = 100; 

} 

void tester_Done(double runTime) 
{ 

    DataTable myTable = new DataTable(); 

    //Here i fill the myTable with rows and columns 

    TestGrid.DataSource = (myTable).DefaultView; 
    TestGrid.DataBind(); 
} 
+0

哪个控件触发将数据绑定到GridView的事件? –

+0

你正在处理哪个事件来填充“myTable”并绑定一个GridView? – adatapost

+0

@AVD,谢谢我编辑了更多代码的问题... – Ovi

回答

0

您需要调用的UpdatePanel的Update()方法以刷新子控件(GridView控件)。

void tester_Done(double runTime) 
{ 
    DataTable myTable = new DataTable(); 

    //Here i fill the myTable with rows and columns 

    TestGrid.DataSource = (myTable).DefaultView; 
    TestGrid.DataBind(); 
    UpdateTestingGrid.Update(); // UpdateMode must be Conditional 
} 
+0

我做到了,但它没有帮助......任何想法为什么? – Ovi

0

请编辑你的问题,以反映与基本对象库有关的问题。

你还看到过这个演示吗? Demo link

我相信您可以在UpdateTestingGrid更新面板中添加隐藏按钮,并在进度条的ClientSideOnTaskDone方法中为此按钮调用__doPostBack方法。 在该按钮的单击事件处理程序中执行gridview数据绑定。

+0

谢谢!你能告诉我你的代码到底是什么意思吗?我是新来的C# – Ovi

相关问题