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

Grid without data binding

1 Answer 122 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kev
Top achievements
Rank 1
Kev asked on 25 Jul 2012, 02:46 AM
Hello,

I want to make a simple grid on my website, allowing the users to input some data in the grid, but I find the demos are a little bit complicate, is there some samples that can fulfill:

- Creating a grid of several columns with known headings (and its data format)
- No need to connect to the database   (No data binding, 0 rows when page load)
- Allow users to add/remove/edit rows
- Can get the input data for calculation when some button is clicked

I know it is a very simple problem, but I cannot find some demos without data binding.



------------------------------------------ Update ------------------------------------------

My current code:
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
    <telerik:RadGrid ID="RadGrid1" runat="server"
        AllowPaging="true" AllowSorting="true" OnDeleteCommand="RadGrid1_DeleteCommand"
        OnInsertCommand="RadGrid1_InsertCommand" AllowFilteringByColumn="false" OnUpdateCommand="RadGrid1_UpdateCommand"
        OnUnload="RadGrid1_Unload">
        <MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="false" DataKeyNames="Field1"
            InsertItemPageIndexAction="ShowItemOnCurrentPage">
             
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" />
                <telerik:GridButtonColumn ConfirmText="Delete this object?" ConfirmDialogType="RadWindow"
                    ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" ConfirmDialogHeight="100px"
                    ConfirmDialogWidth="220px" />
                <telerik:GridBoundColumn DataField="Field1" HeaderText="Field One" UniqueName="Field1" DataType="System.String" />
                <telerik:GridBoundColumn DataField="Field2" HeaderText="Field Two" UniqueName="Field2" DataType="System.Double" />
                <telerik:GridBoundColumn DataField="Field3" HeaderText="Field Three" UniqueName="Field3" DataType="System.String" />
                <telerik:GridBoundColumn DataField="Field4" HeaderText="Field Four" UniqueName="Field4" DataType="System.DateTime" />
            </Columns>                   
        </MasterTableView>
    <ClientSettings>
        <DataBinding Location="WebService.asmx"
            SelectMethod="GetDataAndCount" />
    </ClientSettings>
    </telerik:RadGrid>
</telerik:RadAjaxPanel>


protected void Page_Load(object sender, EventArgs e)
{
     // ...
         
        if (!Page.IsPostBack)
        {
            RadGrid1.DataSource = new Object[0];
        }
}
 
    protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
    {
            // Something
    }
 
    protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
    {
            // Something
    }
 
    protected void RadGrid1_DeleteCommand(object sender, GridCommandEventArgs e)
    {
            // Something
    }
 
    protected void RadGrid1_Unload(object sender, EventArgs e)
    {
            // Something
    }

It can show a empty grid when page load, but when I press the "add new record" button, it do not go into the event.

Regards,
Kev

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 30 Jul 2012, 12:39 PM
Hello Kev,

I'm not sure whether you use client or server binding. I made a simple demo that is based on a server-side binding. Give it a try and then let me know whether it works as expected.

Greetings,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Kev
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or