This is a migrated thread and some comments may be shown as answers.

ReBind Grid on Server Side

3 Answers 219 Views
Grid
This is a migrated thread and some comments may be shown as answers.
hll
Top achievements
Rank 1
hll asked on 10 Nov 2008, 04:19 PM
I need to ReBind the RadGrid on the Server Side.

I have a asp button on my page, and when user clicks, on the OnClick event of that asp button, I need to add some rows to my DataGrid, and bind my grid.

(I have seen the examples that uses input button's to bind radGrid, but i should bind my grid on asp button's OnClick event.)

Is there a way to do this?

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 10 Nov 2008, 04:22 PM
Hi hll,

You can call Rebind() method to achieve this.

Best wishes,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
hll
Top achievements
Rank 1
answered on 10 Nov 2008, 04:45 PM

But I can not see the items I inserted.
Am I missing something?

This is my RadGrid control & asp control on the aspx page.

<asp:Button id="btnSubmit" OnClick="btnSubmit_Click" runat="server" />

<telerik:RadGrid ID="RadGrid1" runat="server" EnableViewState="false"

GridLines="None" Skin="Office2007" AllowSorting="false" AllowMultiRowSelection="true"

AutoGenerateColumns="False" EnableAJAX="True" >

<MasterTableView Width="100%" Summary="RadGrid table">

<Columns>

<telerik:GridBoundColumn HeaderText="Column 1" DataField="Column1" UniqueName="Column1" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>

<telerik:GridBoundColumn HeaderText="Coumn 2" DataField="Column2" UniqueName="Column2" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>

</Columns>

</MasterTableView>

<ClientSettings><Selecting AllowRowSelect="true"/>

</ClientSettings>

</telerik:RadGrid>

--- 
And this is the event of asp button in the cs code;

protected void btnSubmit_Click(object sender, System.EventArgs e)

{

IDictionary tempRow = new System.Collections.Generic.Dictionary<string,string>();

        tempRow.Add("Column1", “1111”);

        tempRow.Add("Column2", “3333”);

        RadGrid1.MasterTableView.InsertItem(tempRow);

RadGrid1.Rebind();

}

0
Iana Tsolova
Telerik team
answered on 13 Nov 2008, 11:24 AM
Hello hll,

Please make sure that your grid is in insert mode. Try modifying your code as below and check if it makes any difference:

protected void btnSubmit_Click(object sender, System.EventArgs e)  
{  
    IDictionary tempRow = new System.Collections.Generic.Dictionary<string,string>();  
    tempRow.Add("Column1", “1111”);  
    tempRow.Add("Column2", “3333”);  
    RadGrid1.MasterTableView.IsItemInserted = true;  
    RadGrid1.MasterTableView.InsertItem(tempRow);  
    RadGrid1.Rebind();  

Let me know if this helps.

All the best,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
hll
Top achievements
Rank 1
Answers by
Vlad
Telerik team
hll
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or