Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
420
Making particular cells editable in an event
posted

Hi all,

         I have developed a windows form application in which I have used Infragistics' UltraGrid Control. I have populated the grid by binding the data at run-time with a dataset. I have a dropdown column in my grid and I have used an event handler for that column once the value is changed from the dropdown(celllist_select event). Now I need to make some particular cells of  the row which I have selected(ActiveRow) as editable, once the dropdownlist item is changed. I will just give a tabular representation of my requirement.

 

ID Amount Formula Projected Value1 Actual Value1 Projected Value2 Actual Value2 Projected Value2 Actual Value2
1 5000 Linear 1000 2000 500 250 1000 3000
2 5000 Manual 100 200 500 1000 400 800

Now in this table, as you can see I have a column called "Formula"  which is a dropdownlist column containing items such as Linear,Manual,Bell Curve,etc; In the second row, I have selected the formula as Manual. So, once I select Manual, I want all the projected values of the 2nd row alone to be editable. Rest of the cells shouldn't be editable. How to achieve this? I don't want to use initializelayout to achieve this functionality. Any help rendered would be of great use.

  • 215
    Suggested Answer
    posted

    Hi,

    You have to call the below code while initializing the grid.

     <igtbl:UltraWebGrid ID="GridName" runat="server"
                                                    AutoGenerateColumns="false"
                                                    DisplayLayout-ActivationObject-BorderColor="Black"
                                                    DisplayLayout-ActivationObject-BorderStyle='Solid'
                                                      oninitializerow="GridName_InitializeRow"       >  

     Write the following code in code behind.

    protected

     

    void GridName_InitializeRow( object sender, Infragistics.WebUI.UltraWebGrid. RowEventArgs e)

    {

     

    for ( int i = 0; i <= e.Row.Cells.Count-1; i++)

    {

     

    if (i > 9)

    {

     

    //editing paricular cell

     

     

     

    e.Row.Cells[i].AllowEditing = Infragistics.WebUI.UltraWebGrid.

     

    AllowEditing

    .Yes;

    e.Row.Cells[i].Style.BackColor = System.Drawing.

     

    Color .White;

    // "white";

    }

     

     

    else

    {

    e.Row.Cells[i].AllowEditing = Infragistics.WebUI.UltraWebGrid.

     

    AllowEditing

    .No;

     

    Hope.it helps :-)

    GnanaPrakash