Setting text after a bind - radtextbox
When I insert a new record in a grid:
<telerik:RadTextBox ID="txtRedemptionBeforeMessage" Text='<%#Bind("RedemptionBeforeMessage") %>' runat="server" />
I want to be able to:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
{
if (e.Item.OwnerTableView.IsItemInserted)
{
//fill in defaults for messages which are required
RadTextBox radTextBox = (RadTextBox)item.FindControl("txtRedemptionBeforeMessage");
radTextBox.Text = "default redemption before message";
This works when there is no Text='<%#Bind("RedemptionBeforeMessage") %>
Problem: how to I get a default message to work - I suspect I n开发者_如何学Ceed to look at an event after the bind.
The Bind is in there because the same form code is used to edit.
Already answered your question in this thread - Setting text after a bind - radtextbox
Dave, see paragraph #3 here - should get you up and going.
Here is the code I used to get it working:
public void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.InitInsertCommandName)
{
//fill in defaults for messages which are required
e.Canceled = true;
ListDictionary newValues = new ListDictionary();
newValues.Add("name", "default name message");
newValues.Add("blahblahbindablename", "default blah blah message");
//Insert the item and rebind
e.Item.OwnerTableView.InsertItem(newValues);
}
}
精彩评论