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

Blank Grid open in Insert Mode

3 Answers 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Elliott
Top achievements
Rank 2
Elliott asked on 02 Jun 2010, 04:17 PM
How do I set up a blank grid to start inserting data?  All I get is a blank screen
I am using VS 2010 with a trial copy of Telerik RAD controls

<%@ Page Title="" Language="VB" MasterPageFile="~/Brunswick.master" AutoEventWireup="false" CodeFile="FastItemEntry.aspx.vb" Inherits="FastItemEntry" %> 
<asp:Content ID="cntHead" ContentPlaceHolderID="cpHead" Runat="Server"
</asp:Content> 
<asp:Content ID="cntBody" ContentPlaceHolderID="cpHolder" Runat="Server"
    <telerik:RadScriptManager ID="rsManager" Runat="server"
    </telerik:RadScriptManager> 
    <telerik:RadAjaxManager ID="raManager" runat="server"
    </telerik:RadAjaxManager> 
    <table border="0" cellpadding="0" cellspacing="0"
    <tr> 
    <td> 
        <telerik:RadGrid ID="rgAddItems" AutoGenerateColumns="False" GridLines="Both" runat="server"
            <MasterTableView DataKeyNames="ItemID" CommandItemDisplay="Bottom" NoDetailRecordsText="begin entering data" runat="server"
            <Columns> 
                <telerik:GridBoundColumn DataField="ItemID" Visible="false" /> 
                <telerik:GridBoundColumn UniqueName="PartNumber" DataField="PartNumber" HeaderText="Part Number" /> 
                <telerik:GridBoundColumn UniqueName="ItemDescription" DataField="ItemDescription" HeaderText="Description" /> 
                <telerik:GridTemplateColumn> 
                    <ItemTemplate> 
                        <asp:Label ID="lblQty" runat="server" /> 
                    </ItemTemplate> 
                    <EditItemTemplate> 
                        <telerik:RadNumericTextBox ID="rntbQty" NumberFormat-DecimalDigits="0" NumberFormat-GroupSizes="9" runat="server" > 
                        </telerik:RadNumericTextBox> 
                    </EditItemTemplate> 
                </telerik:GridTemplateColumn> 
            </Columns> 
            </MasterTableView> 
        </telerik:RadGrid> 
     </td> 
     </tr> 
    </table> 
</asp:Content> 
 
Imports System.Data 
 
Partial Class FastItemEntry 
    Inherits System.Web.UI.Page 
 
    Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load 
        If Page.IsPostBack Then 
        Else 
            rgAddItems.MasterTableView.IsItemInserted = True 
            rgAddItems.Rebind() 
        End If 
    End Sub 
 
    Protected Sub rgAddItems_ItemCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgAddItems.ItemCommand 
 
    End Sub 
 
    Protected Sub rgAddItems_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles rgAddItems.NeedDataSource 
        Dim dt As DataTable = Nothing 
        rgAddItems.DataSource = dt 
    End Sub 
End Class 

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 03 Jun 2010, 11:01 AM
Hello Marianne,

Try the following code snippet in Page_Load event to set up a blank grid to start inserting data.

VB.Net:
 
 Protected Sub Page_Load(sender As Object, e As EventArgs) 
  If Not IsPostBack Then 
     RadGrid1.MasterTableView.IsItemInserted = True 
     RadGrid1.DataSource = String.Empty 
  End If 
 End Sub 
 

Regards,
Shinu.
0
Elliott
Top achievements
Rank 2
answered on 03 Jun 2010, 05:37 PM
thanks
I had dummied up a row in a DataTable and bound it to that
your solution is cleaner

however, I need to add some attributes to the newly created Edit row
would you know of an event on either the server side (preferable) or client side when a row opens to Insert?
0
Daniel
Telerik team
answered on 08 Jun 2010, 01:15 PM
Hello Marianne,

Please try the following approach:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is IGridInsertItem)
    {
        //...
    }
}

Protected Sub RadGrid1_ItemCreated(sender As Object, e As GridItemEventArgs) Handles RadGrid1.ItemCreated
    If TypeOf e.Item Is IGridInsertItem Then
            '...
    End If
End Sub


Regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Elliott
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 1
Elliott
Top achievements
Rank 2
Daniel
Telerik team
Share this question
or