Multi-add and Multi-edit for Grid

17 posts, 0 answers
  1. Simon Kingaby
    Simon Kingaby avatar
    24 posts
    Member since:
    Apr 2008

    Posted 08 Aug 2008 Link to this post

    I need to be able to allow users to add or edit multiple rows in a RadGrid.  For example, they may open the grid page and see three rows.  They click the Edit button in row 2 and row 3.  They add a new row 4, then another new row 5.

    My grid is bound to a List(Of ), not a DataSet.

    I managed to get the add to work by adding a new item to the collection and rebinding the grid. 

    However, whenever the user adds another item, the rows are reset and the changes in the edited rows are lost.

    I created a sample solution that attempts to demonstrate this behavior, but there is an error in the javascript when you click the Add Thing button.

    The code is here: http://tinyurl.com/6yq7zc

    When you run it, the collection of Things is loaded with 10 Thing objects.  This is bound to the grid.  You can click the edit button in a row to toggle that row into edit mode.  I want to be able to click the Add Thing button in the Command Bar to Add one or more new Things with each being in Edit mode so the user can add a bunch of Thing objects and then fill in the details for the set of them.

    Thanks for your help.

  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 12 Aug 2008 Link to this post

    Hello Simon,

    The setup which you described is already being addressed in the support ticket opened on the matter. To avoid duplicate posts, we can continue our communication there.

    Sincerely yours,
    Yavor
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. The Oracle
    The Oracle avatar
    46 posts
    Member since:
    Aug 2012

    Posted 16 Sep 2008 Link to this post

    How did this turn out?  I have a grid with multiple rows in edit mode, and I want to issue an Update from an outside button.  If there is an error, the error is displayed in my error div, but the changes to the edited records are all lost.

    Please help!

    Thanks,
    Graeme
  5. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 17 Sep 2008 Link to this post

    Hello,

    The only solution in this case is, whenever a new command is raised, to preserve the already edited items in the database. The following topic shows how to iterate through all the items in the control, and get the values. Then, these can be updated in the underlying database.
    I hope this helps.

    Kind regards,
    Yavor
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Simon Kingaby
    Simon Kingaby avatar
    24 posts
    Member since:
    Apr 2008

    Posted 17 Sep 2008 Link to this post

    So here is the solution I came up with.  

    First, for anyone else who reads this thread, I am binding my grid to a Collection, not a DataSet.  So I have an in-memory representation of my data that will not automatically write changes back to the database until I tell it to SaveChanges().

    Summary: I need to be able to Add/Edit multiple rows in a Grid without losing the changes made to other Added/Edited rows that have not yet been saved.

    Solution: Before any Add or Edit operation, I need to scrape the values off the edit row controls into the relevant object in the Collection data source.

    Here is the code in the ItemCommand event handler where I Add a new item:


    Private Sub RadGrid1_ItemCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand   
      If e.CommandName = "AddNewThing" Then   
          ScrapeAllEditRows()   
          Dim aThing As New Thing   
          aThing.Guid = Guid.NewGuid()   
          ThingController.Things.Add(aThing)   
          _newThing = aThing   
          RadGrid1.Rebind()   
      End If   
    End Sub  

    And here is the code in the EditCommand event handler:

    Private Sub RadGrid1_EditCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.EditCommand   
      ScrapeAllEditRows()   
    End Sub  

    Lastly, the ScrapeAllEditRows() method loops through the rows like this:

    Private Sub ScrapeAllEditRows()   
        For Each item As GridDataItem In RadGrid1.MasterTableView.Items   
            If item.IsInEditMode Then   
       
                'get the key out of the row   
                Dim key As Guid   
                key = item.OwnerTableView.DataKeyValues(item.ItemIndex)("Guid")   
       
                'get the thing out of the collection for the key   
                Dim thing As Thing = ThingController.Things.FindByGuid(key)   
       
                thing.Name = DirectCast(item("NameColumn").Controls(0), TextBox).Text   
                thing.ShapeType = DirectCast(item.FindControl("RadComboBox1ShapeType"), RadComboBox).SelectedValue   
            End If   
        Next   
    End Sub  

  7. Simon Kingaby
    Simon Kingaby avatar
    24 posts
    Member since:
    Apr 2008

    Posted 17 Sep 2008 Link to this post

    The ScrapeAllRows code above is the code that I used to handle the multi-edit feature where you have one or more rows in edit mode, then click edit on another row, or execute any command in the grid, only to watch the grid refresh and wipe out all the changes made so far.

    I.e. Create a grid with multi-edit turned on.  Toggle a row into edit and make a change, now toggle another row into edit and see how the first change is lost.  Right. 
    The ScrapeAllRows is one way (so far the only way I know of) to work around this.  Essentially this is caching the changes made to existing rows in the collection the grid is bound to, without saving the changes to the database, and then rewriting them back to the grid when it re-renders.  If the grid were to be Refreshed or the edit Canceled, I force a reload of the collection or object so the cached changes are not persisted to the database.
  8. Simon Kingaby
    Simon Kingaby avatar
    24 posts
    Member since:
    Apr 2008

    Posted 17 Sep 2008 Link to this post

    As far as the Multi-Add.   Here is the code that makes that work.  In combination with the ScrapeAllRows code, this makes for a RadGrid that you can multi-add, and multi-edit, without losing changes made so far.

    In the Grid, add a button in the CommandItemTemplate that calls your custom Add command.  (AddNewThing in this example).

    <CommandItemTemplate>    
        <table width="100%">     
            <tr>    
                <td>    
                    <asp:LinkButton ID="LinkButton2" runat="server" CommandName="AddNewThing" Text="Add Thing" />    
                </td>    
            </tr>    
        </table>    
    </CommandItemTemplate>   

    In the code behind, you need to fake out the Add.  We're actually going to add the item to the collection, and save it to the database, and then reload the grid with that item in edit mode, so we actually skip the whole "ItemInserted" event.  The grid does some strange binding things for inserted rows, and will only allow one row in insert mode at a time.  This code works around that.

    Remember, I am binding my grid to a Collection, NOT a DataSet, and I am NOT using a Object/SQL/Etc.DataSource of any sort.  All the binding is handled in the code.

    Private Sub RadGrid1_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource  
        Me.RadGrid1.DataSource = ThingController.Things  
    End Sub 

    So, first, we need to handle the AddNewThing command, like this:

    Private Sub RadGrid1_ItemCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand  
        If e.CommandName = "AddNewThing" Then 
            ScrapeAllEditRows()  
            Dim aThing As New Thing  
            aThing.Guid = Guid.NewGuid()  
            aThing.EstimatedBirthMonth = Date.Now.ToLongTimeString  
            ThingController.Things.Add(aThing)  
            _newThing = aThing  
            RadGrid1.Rebind()  
        End If 
    End Sub 

    Next, notice how we set the class variable _newThing equal to the new aThing that we just created?  When the Grid rebinds, we can catch the PreRender event and check to see if there is a Thing in the _newThing variable, if there is, then we must have just added one, and we need to make it editable and Rebind the grid again (Yes, rebind again, it's weird that way.), like this:

    Private Sub RadGrid1_PreRender(ByVal sender As ObjectByVal e As System.EventArgs) Handles RadGrid1.PreRender  
        If _newThing IsNot Nothing Then 
            For Each item As GridDataItem In RadGrid1.MasterTableView.Items  
                Dim aThing As CodeForTelerik.Thing = DirectCast(item.DataItem, Thing)  
                If aThing.Guid.Equals(_newThing.Guid) Then 
                    If Not item.IsInEditMode Then 
                        'clear the newdeal reference and set the row into edit mode    
                        _newThing = Nothing 
                        item.Edit = True 
                        RadGrid1.MasterTableView.Rebind()  
                        Exit Sub 
                    End If 
                End If 
            Next 
        End If 
    End Sub 

    As with the ScrapeAllRows code, we are messing with the in-memory collection, so we are not persisting any of these changes into the database until the user tells us to.  If the user Cancels or Refreshes, the collection/object is reloaded from the database and the new item is discarded.

    I hope that helps.  Please post to this thread if you have any questions or if you have a better suggestion (please, I wish I knew a better way to do this).



  9. The Oracle
    The Oracle avatar
    46 posts
    Member since:
    Aug 2012

    Posted 17 Sep 2008 Link to this post

    Simon!

    Great solution!  And you inspired me to another (not-exactly-fully-blown) solution.

    We can use their ExtractValuesFromItem to produce a Hashtable which we save for ItemDataBound.  Then, if there is an error, override the databinding with the value from the Hashtable.  Like this [This uses Northwind.mdb.]:

    ASPX: multi-row edit Grid; external "Update" button:

    1 <radx:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" GridLines="None" 
    2     OnPreRender="RadGrid1_PreRender" AllowMultiRowEdit="True"  
    3     OnNeedDataSource="RadGrid1_NeedDataSource" OnItemDataBound="RadGrid1_ItemDataBound">  
    4     <MasterTableView DataKeyNames="CustomerID" EditMode="inPlace">  
    5         <RowIndicatorColumn> 
    6             <HeaderStyle Width="20px" /> 
    7         </RowIndicatorColumn> 
    8         <ExpandCollapseColumn> 
    9             <HeaderStyle Width="20px" /> 
    10         </ExpandCollapseColumn> 
    11         <Columns> 
    12             <radx:GridBoundColumn DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True" 
    13                 SortExpression="CustomerID" UniqueName="CustomerID">  
    14             </radx:GridBoundColumn> 
    15             <radx:GridBoundColumn DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName" 
    16                 UniqueName="ContactName">  
    17             </radx:GridBoundColumn> 
    18             <radx:GridBoundColumn DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName" 
    19                 UniqueName="CompanyName">  
    20             </radx:GridBoundColumn> 
    21         </Columns> 
    22     </MasterTableView> 
    23     <ClientSettings> 
    24         <Selecting AllowRowSelect="True" /> 
    25     </ClientSettings> 
    26     <FilterMenu EnableTheming="True">  
    27         <CollapseAnimation Duration="200" Type="OutQuint" /> 
    28     </FilterMenu> 
    29 </radx:RadGrid> 
    30 <asp:Literal ID="ErrorsLiteral" runat="server"></asp:Literal> 
    31 <asp:Button ID="Button1" runat="server" CommandName="Update" OnCommand="Button_Command" 
    32     Text="Update" /> 
    33  

    Code: Button_Command which throws an error (so we can see if the edit values are preserved) and Item_DataBound handler which compares/replaces the bound values with edit values:

    1 protected void Button_Command(object sender, CommandEventArgs e)  
    2 {  
    3     switch (e.CommandName)  
    4     {  
    5         case "Update":  
    6             try 
    7             {  
    8                 CacheEditValues();  
    9                 foreach (GridEditableItem editItem in this.RadGrid1.EditItems)  
    10                 {  
    11                     //Throw out an error to interfere with the save.  Will edit values be preserved?  
    12                     throw new InvalidOperationException("this is a bad thing.");  
    13                 }  
    14                 isError = false;  
    15             }  
    16             catch (InvalidOperationException ix)  
    17             {  
    18                 isError = true;  
    19                 List<string> errorList = new List<string>();  
    20                 errorList.Add(ix.Message);  
    21                 DisplayErrors(errorList);  
    22             }  
    23             break;  
    24     }  
    25 }  
    26  
    27 private bool isError = false;  
    28 private List<Hashtable> hashList = new List<Hashtable>();  
    29 private void CacheEditValues()  
    30 {  
    31     foreach (GridEditableItem editItem in this.RadGrid1.EditItems)  
    32     {  
    33         Hashtable newValues = new Hashtable();  
    34         editItem.OwnerTableView.ExtractValuesFromItem(newValues, editItem);  
    35         hashList.Add(newValues);  
    36     }  
    37 }  
    38  
    39 protected void RadGrid1_PreRender(object sender, EventArgs e)  
    40 {  
    41     //Show all the rows as editable.  
    42     foreach (GridDataItem dataItem in this.RadGrid1.Items)  
    43     {  
    44         dataItem.Edit = true;  
    45     }  
    46     this.RadGrid1.Rebind();  
    47 }  
    48  
    49 protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)  
    50 {  
    51     string query = "SELECT TOP 10 [CustomerID], [ContactName], [CompanyName] FROM [Customers]";  
    52     this.RadGrid1.DataSource = DataSourceHelper.GetDataTable(query);  
    53 }  
    54 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    55 {  
    56     if (isError && e.Item.Edit && e.Item.RowIndex > -1 && e.Item.RowIndex < hashList.Count)  
    57     {  
    58         GridEditableItem editItem = e.Item as GridEditableItem;  
    59         //put things back  
    60         Hashtable ht = hashList[e.Item.RowIndex];  
    61         foreach (DictionaryEntry de in ht)  
    62         {  
    63             Control c = editItem[de.Key.ToString()].Controls[0];  
    64             switch (c.GetType().Name)  
    65             {  
    66                 case "TextBox":  
    67                     TextBox tb = (c as TextBox);  
    68                     if (tb.Text != de.Value.ToString())  
    69                     {  
    70                         (c as TextBox).Text = de.Value.ToString();  
    71                     }  
    72                     break;  
    73             }  
    74         }  
    75     }  
    76 }  
    77  
    78 private void DisplayErrors(List<String> errorList)  
    79 {  
    80     StringBuilder sb = new StringBuilder();  
    81     sb.Append("<ul style=\"color:red;\">");  
    82     for (int i = 0; i < errorList.Count; i++)  
    83     {  
    84         string s = errorList[i];  
    85         sb.Append("<li>");  
    86         sb.Append(s);  
    87         sb.Append("</li>");  
    88     }  
    89     sb.Append("</ul>");  
    90     this.ErrorsLiteral.Text = sb.ToString();  
    91 }  
    92  
    93 private void ClearErrors()  
    94 {  
    95     this.ErrorsLiteral.Text = "";  
    96 }  
    97  

    In my production environment, I also use a typed DataCollection, which can make it even easier to compare values (e.g., DirectCast( editItem.DataItem, Thing)).  Sorry if my VB is faulty. :-)

    Also, I didn't do the row control like you did, nor did I test for other control types, but I didn't want to muck up my keen-o example with a lot of annoying details. ;-)

    Thanks very much, Simon.  Let me know what you think, if you have a moment (even if you have to tactfully bring me down to earth).

    Graeme

  10. The Oracle
    The Oracle avatar
    46 posts
    Member since:
    Aug 2012

    Posted 17 Sep 2008 Link to this post

    Well, that bites.  It was working, but now is not.  I guess you get the idea, but you really need some method of row control.  This is too rigid.

    Graeme
  11. The Oracle
    The Oracle avatar
    46 posts
    Member since:
    Aug 2012

    Posted 17 Sep 2008 Link to this post

    OK, it works, if you use ItemIndex instead of RowIndex in Item_DataBound.  But it's best to use row control, like you did, or thus:

    1 private void CacheEditValues()  
    2 {  
    3  
    4     foreach (GridEditableItem editItem in this.RadGrid1.EditItems)  
    5     {  
    6         Hashtable newValues = new Hashtable();  
    7         newValues.Add("CustomerID", editItem.OwnerTableView.DataKeyValues[editItem.ItemIndex]["CustomerID"]);  
    8         editItem.OwnerTableView.ExtractValuesFromItem(newValues, editItem);  
    9         hashList.Add(newValues);  
    10     }  
    11 }  
    12  

    ...and then look up the particular HT later, by the PK.

    Graeme
  12. The Oracle
    The Oracle avatar
    46 posts
    Member since:
    Aug 2012

    Posted 17 Sep 2008 Link to this post

    SIMON!!

    I figured out another way to do this via a collection.  If there is an error (or whatever your flag is--isInserting, e.g.), you can modify the collection using the cached values during the NeedDataSource event handler before you assign it to the DataSource of the Grid.  So if you wanted to do an "AddNew,"  or whatever, you could add an empty/default object to the Collection before binding.  Check it out (remember isError is my flag to say we are rebinding due to an error during validation):


    1 OrderDetailViews views = new OrderDetailViews();  
    2 views.Sort("ID", System.ComponentModel.ListSortDirection.Ascending);  
    3  
    4 if (isError)  
    5 {  
    6     foreach (OrderDetailView view in views)  
    7     {  
    8         //put things back  
    9         Hashtable ht = hashList[view.ID] as Hashtable; //hashList[e.Item.ItemIndex];  
    10         DateTime? selectedDate;  
    11  
    12         if (view.IsOrdered != Convert.ToBoolean(ht["IsOrdered"])) { view.IsOrdered = Convert.ToBoolean(ht["IsOrdered"]); }  
    13         if (view.Quantity != Convert.ToInt32(ht["Quantity"])) { view.Quantity = Convert.ToInt32(ht["Quantity"]); }  
    14         if (view.CancelQuantity != Convert.ToInt32(ht["CancelQuantity"])) { view.CancelQuantity = Convert.ToInt32(ht["CancelQuantity"]); }  
    15         if (view.ReceiveQuantity != Convert.ToInt32(ht["ReceiveQuantity"])) { view.ReceiveQuantity = Convert.ToInt32(ht["ReceiveQuantity"]); }  
    16         if (view.BackOrderQuantity != Convert.ToInt32(ht["BackOrderQuantity"])) { view.BackOrderQuantity = Convert.ToInt32(ht["BackOrderQuantity"]); }  
    17         if (view.UnitPrice != Convert.ToDecimal(ht["UnitPrice"])) { view.UnitPrice = Convert.ToDecimal(ht["UnitPrice"]); }  
    18         if (view.Comment != ht["Comment"].ToString()) { view.Comment = ht["Comment"].ToString(); }  
    19  
    20         selectedDate = (DateTime?)ht["BackOrderETADate"];  
    21         if (selectedDate.HasValue && view.BackOrderETADate != selectedDate.Value)  
    22         {  
    23             view.BackOrderETADate = selectedDate.Value;  
    24         }  
    25         else 
    26         {  
    27             view.BackOrderETADate = DateTimeHelper.EmptyDate;  
    28         }  
    29  
    30     }  
    31 }  
    32  
    33 this.OrderDetailRadGrid.DataSource = views;  
    34  
  13. The Oracle
    The Oracle avatar
    46 posts
    Member since:
    Aug 2012

    Posted 17 Sep 2008 Link to this post

    Hey, Simon--

    I forgot to mention that I changed the List<Hashtable> to a ListDictionary (so that I could have key access to the items):

    1 private bool isError = false;  
    2 private ListDictionary hashList = new ListDictionary();  
    3  
    4 private void CacheEditValues()  
    5 {  
    6     foreach (GridEditableItem editItem in this.OrderDetailRadGrid.EditItems)  
    7     {  
    8         Hashtable newValues = new Hashtable();  
    9         object key = editItem.OwnerTableView.DataKeyValues[editItem.ItemIndex]["ID"];  
    10         editItem.OwnerTableView.ExtractValuesFromItem(newValues, editItem);  
    11         hashList.Add(key, newValues);  
    12     }  
    13 }  
    14  

    Graeme
  14. Simon Kingaby
    Simon Kingaby avatar
    24 posts
    Member since:
    Apr 2008

    Posted 18 Sep 2008 Link to this post

    When you use the OnDataBind instead of the PreRender event, are you seeing the code run more or less often?  Is the performance better?  Thx.

    Most of my columns use ItemTemplates and EditTemplates, so I have to extract the items manually and this code: 
    editItem.OwnerTableView.ExtractValuesFromItem(newValues, editItem);   
    won't work for me.  Otherwise, that's a cool twist on the collection based solution.
  15. The Oracle
    The Oracle avatar
    46 posts
    Member since:
    Aug 2012

    Posted 18 Sep 2008 Link to this post

    Hey, Simon--

    You had mentioned that you use a Collection and the NeedDataSource handler, just as I do.  I found as you did that the place we lose the edits is on Rebind, usually following a full postback or a call to that method.  Therefore, if I modify the bound data during the NeedDataSource handler (before it's bound), it will always be right. 

    I don't know if the PreRender runs often without the NeedDataSource firing first, but since I do multi-row edits, I have to call Rebind() before it goes out.  (I still don't understand that one.)  Since I call Rebind(), it naturally goes through NeedDataSource again.

    I use mostly Template columns on the form in question, and the use of
    1 editItem.OwnerTableView.ExtractValuesFromItem(newValues, editItem); 
    ...works for me.  I'm using the <%# Bind("..") %> constructs.  Are you doing something different?

    Graeme
  16. The Oracle
    The Oracle avatar
    46 posts
    Member since:
    Aug 2012

    Posted 18 Sep 2008 Link to this post

    Dear Simon,

    This is interesting.  All my GridTemplateColumn bound fields come through fine.  However, I have one GridTemplateColumn which I bind from ItemDataBound event handler.  As a consequence, the value is not directly available for ExtractValuesFromItems.

    Now I have modified CacheEditValues to accommodate that one column by requesting its value specifically, and manually adding it to the Hashtable:
    1 private void CacheEditValues()  
    2 {  
    3     foreach (GridEditableItem editItem in this.PartsToOrderViewRadGrid.EditItems)  
    4     {  
    5         Hashtable newValues = new Hashtable();  
    6         object key = editItem.OwnerTableView.DataKeyValues[editItem.ItemIndex]["PartID"];  
    7         editItem.OwnerTableView.ExtractValuesFromItem(newValues, editItem);  
    8         //doesn't pick up the DefaultVendorID from the combo  
    9         long defaultVendorID = Convert.ToInt64((editItem.FindControl("PartVendorCombo"as RadComboBox).SelectedValue);  
    10         newValues.Add("DefaultVendorID", defaultVendorID);  
    11         hashList.Add(key, newValues);  
    12     }  
    13 }  
    14  

    "Works a treat!" as they say in England (is that where They say it? ;-)

    Graeme
  17. Simon Kingaby
    Simon Kingaby avatar
    24 posts
    Member since:
    Apr 2008

    Posted 18 Sep 2008 Link to this post

    80% of the columns in my grid are Combos, so I have the same issue as your exception, and it never occurred to me to pull the ExtractValues. 

    Most of my binding is done with this syntax:

    Text='<%# (DirectCast(Container.DataItem, Png.Gcs35.Domain.Deal).BACell) %>' 

    As in this example:

    <telerik:GridTemplateColumn HeaderText="Bus. Associate" UniqueName="BusAssociateColumn" 
        SortExpression="BACell">  
        <HeaderStyle Width="200px" HorizontalAlign="Left" /> 
        <ItemTemplate> 
            <asp:Label ID="LabelBACell" runat="server" Text='<%# (DirectCast(Container.DataItem, Png.Gcs35.Domain.Deal).BACell) %>' /> 
        </ItemTemplate> 
        <EditItemTemplate> 
            <table border="0" cellpadding="0" cellspacing="0" style="border-left: none; border-bottom: none;" 
                width="100%">  
                <tr> 
                    <td style="border-left: none; border-bottom: none;" width="100%">  
                        <asp:Label ID="LabelBACellEdit" runat="server" Text='<%# (DirectCast(Container.DataItem, Png.Gcs35.Domain.Deal).BACell) %>' /> 
                    </td> 
                </tr> 
                <tr> 
                    <td style="border-left: none; border-bottom: none;" width="100%">  
                        <pnggcs:BusinessAssociateComboBox ID="BusinessAssociateComboBox1" runat="server" 
                            AutoPostBack="true" Style="margin-right: 0px" Width="195px" DropDownWidth="400px" 
                            OnSelectedIndexChanged="BusinessAssociateComboBox1_SelectedIndexChanged" /> 
                    </td> 
                </tr> 
            </table> 
        </EditItemTemplate> 
    </telerik:GridTemplateColumn> 
     
  18. The Oracle
    The Oracle avatar
    46 posts
    Member since:
    Aug 2012

    Posted 18 Sep 2008 Link to this post

    So is it possible to reach your custom BusinessAssociateComboBox and read the value like I did?  And your SelectedIndexChanged causes the PostBack, doesn't it?

    As the GridDropDownColumn doesn't do everything :-), we end up using Templates.  In my situation, I needed to support the loading of items in my combo via web service.  This is what I ended up doing (using a RadComboBox, in this case):

    1 <radx:GridTemplateColumn UniqueName="DefaultVendorIDCol" HeaderText="Vendor" DataField="DefaultVendorID" 
    2     SortExpression="DefaultVendorID">  
    3     <ItemTemplate> 
    4         <asp:Label ID="VendorLabel" runat="server"></asp:Label></ItemTemplate>  
    5     <EditItemTemplate> 
    6         <radx:RadComboBox ID="PartVendorCombo" runat="server" DataTextField="PartVendorName" 
    7             DataValueField="PartVendorID" Skin="WebBlue" EnableLoadOnDemand="true" Height="240px" 
    8             AllowCustomText="false" ShowMoreResultsBox="false" NoWrap="false" MaxLength="500" 
    9             OnClientItemsRequesting="comboItemsRequesting" OnClientItemsRequested="comboItemsRequested" 
    10             OnClientSelectedIndexChanged="comboIndexChanged">  
    11         </radx:RadComboBox> 
    12     </EditItemTemplate> 
    13 </radx:GridTemplateColumn> 
    14  

    Graeme
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017