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

Sugest a value for New Record

1 Answer 43 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Clive Hoggar
Top achievements
Rank 1
Clive Hoggar asked on 25 Nov 2009, 08:34 PM
In my popup edit form I have a templated column "TTL" and its TextBox   "TTLTextBox".
I want to suggest a value for this, and have used this code, which does not presen an inital value,
but has no error messages. Can you tell me why?
Thanks
Clive
Private Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated  
        If TypeOf e.Item Is GridEditableItem And e.Item.IsInEditMode Then  
 
            If e.Item.OwnerTableView.IsItemInserted Then  
                'item is about to be inserted  
                Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem)  
                Dim TxtBx As TextBox = DirectCast(item.FindControl("TTLTextBox"), TextBox)  
                TxtBx.Text = "21" 
 
            Else  
                'item is about to be edited  
            End If  
        End If  
    End Sub 

the rekevant column declaration is

<

 

telerik:GridTemplateColumn DataField="TTL"

 

 

DataType="System.Int16" HeaderText="TTL"

 

 

SortExpression="TTL" UniqueName="TTL">

 

 

<EditItemTemplate>

 

 

<asp:TextBox ID="TTLTextBox" runat="server" Text='<%# Bind("TTL") %>'

 

 

Width="30px" MaxLength="3" style="text-align:right"></asp:TextBox>

 

 

</EditItemTemplate>

 

 

<ItemTemplate>

 

 

<asp:Label ID="TTLLabel" runat="server"

 

 

Text='<%# Eval("TTL") %>'></asp:Label>

 

 

</ItemTemplate>

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Nov 2009, 05:02 AM
Hi Clive,

Your code worked when I tried in ItemDataBound event of grid. Give a try with the same code in ItemDataBound event instead of ItemCreated.

-Shinu.
Tags
Grid
Asked by
Clive Hoggar
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or