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

[Solved] PopUp Edit Form with Inserts

2 Answers 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 09 Sep 2009, 07:19 PM
I have a grid and use a popup edit form that I have created a template for.  On the edit event it will bind my fields just fine but now I am trying to add insert functionality as well. The problem is that I have a radio button list on the edit form that I set using the following:

<

 

asp:RadioButtonList ID="rbAnalyst" runat="server" RepeatDirection="Horizontal" SelectedValue='<%# Bind("ANALYST_IND")%>'>

 

 

<asp:ListItem Value="Y">Yes</asp:ListItem>

 

 

<asp:ListItem Value="N">No</asp:ListItem>

 

 

</asp:RadioButtonList>

 


I am not positive but I think it is trying to bind a non-breaking space... &nbsp;

Obviously adding a new record will not be able to bind a N or Y.  Can I capture the "InitInsert" on the ItemCommand event and set the value of the new grid row record to a default of say 'N' before the edit form binding occurs?  If so, how do I do this?

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 10 Sep 2009, 05:30 AM
Hello Robert,

You can try out the following code to set a predefined value on the InitInsert command of your grid:
c#:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == RadGrid.InitInsertCommandName) 
           {               
               e.Canceled = true;               
               System.Collections.Specialized.ListDictionary newValues = new 
               System.Collections.Specialized.ListDictionary(); 
               newValues[ "ANALYST_IND"] = "N";               
               e.Item.OwnerTableView.InsertItem(newValues); 
           } 
    } 

Thanks
Princy.
0
Robert
Top achievements
Rank 1
answered on 10 Sep 2009, 01:38 PM
Thanks man.
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Robert
Top achievements
Rank 1
Share this question
or