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
140
Set CellText value with Infragistic checkBox from code behind in c#
posted

Hi,

 i am Implementing Web Hirarchical Data Grid and i have a checkBox , i want to set the Value of cell Text from Server side as each cell text can have different Value . Both Front end and BackEnd Code is :

<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" runat="server" AutoGenerateBands="False"
AutoGenerateColumns="False" DataKeyFields="id" DataMember="Module" EnableViewState="true"
ViewStateMode="Enabled"
InitialExpandDepth="3" InitialDataBindDepth="3"
Height="350px" Width="900px" >
<%--<ClientEvents Initialize="InitializHandler" Click="ClickHandler"/>--%>
<%-- <AutoPostBackFlags RowSelectionChanged="false" />--%>
<%--<AutoPostBackFlags CellSelectionChanged="Of" />--%>
<Columns>
<ig:BoundDataField DataFieldName="id" Hidden="true" DataType="System.Int32" Key="id" Width="100px">
<Header Text="Module ID" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Item" DataType="System.String" Key="Item">
<Header Text="Module Description" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Data" Hidden="true" DataType="System.String" Key="Data">
<Header Text="Operations" />
</ig:BoundDataField>
<%--<ig:BoundCheckBoxField DataFieldName="View" DataType="System.Boolean" Key="View">
<Header Text="View" />
</ig:BoundCheckBoxField>
<ig:BoundCheckBoxField DataFieldName="Update" DataType="System.Boolean" Key="Update">
<Header Text="Update" />
</ig:BoundCheckBoxField>
<ig:BoundCheckBoxField DataFieldName="Delete" DataType="System.Boolean" Key="Delete">
<Header Text="Delete" />
</ig:BoundCheckBoxField>
<ig:BoundCheckBoxField DataFieldName="Save" DataType="System.Boolean" Key="Save">
<Header Text="Save" />
</ig:BoundCheckBoxField>--%>
</Columns>

<Bands>
<ig:Band AutoGenerateColumns="False" DataKeyFields="Item" DataMember="TRN_CODE" Key="ChildBand_0">
<Columns>

<%-- <ig:BoundDataField DataFieldName="ChildTableId" Hidden="false" DataType="System.Int32" Key="ChildTableId">
<Header Text="ChildTableId" />
</ig:BoundDataField>--%>
<ig:BoundDataField DataFieldName="ChildId" Hidden="true" DataType="System.Int32" Key="DataCh">
<Header Text="Child Id" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Item" DataType="System.String" Key="ItemCh">
<Header Text="Child Item" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="ParentId" Hidden="true" DataType="System.Int32" Key="idCh">
<Header Text="Parent ID" />
</ig:BoundDataField>
<%--<ig:BoundDataField DataFieldName="Operations" Hidden="false" DataType="System.String" Key="Operations">
<Header Text="Operations" />
</ig:BoundDataField>--%>
<ig:BoundCheckBoxField DataFieldName="Operations" Key="Operations" CellText="WanttoGetValuefromServer">
<Header Text="Operations" />
</ig:BoundCheckBoxField>
<%--<ig:BoundCheckBoxField DataFieldName="ChView" DataType="System.Boolean" Key="ChView">
<Header Text="View" />
</ig:BoundCheckBoxField>
<ig:BoundCheckBoxField DataFieldName="ChUpdate" DataType="System.Boolean" Key="ChUpdate">
<Header Text="Update" />
</ig:BoundCheckBoxField>
<ig:BoundCheckBoxField DataFieldName="ChDelete" DataType="System.Boolean" Key="ChDelete">
<Header Text="Delete" />
</ig:BoundCheckBoxField>
<ig:BoundCheckBoxField DataFieldName="ChSave" DataType="System.Boolean" Key="ChSave">
<Header Text="Save" />
</ig:BoundCheckBoxField>--%>

</Columns>

<Behaviors>
<ig:EditingCore BatchUpdating="True">
<Behaviors>
<ig:RowAdding/>
<ig:RowDeleting/>
<ig:CellEditing/>
</Behaviors>
</ig:EditingCore>
<%--<ig:EditingCore AutoCRUD="false">
<Behaviors>
<ig:CellEditing>
<ColumnSettings>
<ig:EditingColumnSetting ColumnKey="ItemCh" ReadOnly="true" />
</ColumnSettings>

</ig:CellEditing>
</Behaviors>
</ig:EditingCore>--%>
</Behaviors>
</ig:Band>
</Bands>


<Behaviors>

<ig:Selection CellClickAction="Row" CellSelectType="None" RowSelectType="Single">
<AutoPostBackFlags CellSelectionChanged="false" RowSelectionChanged="false" ColumnSelectionChanged="false" />
<%--<AutoPostBackFlags RowSelectionChanged="false" />--%>

</ig:Selection>
<ig:Activation>
</ig:Activation>
<ig:EditingCore BatchUpdating="True"/>

<%--<ig:EditingCore>
<Behaviors>

<ig:CellEditing>
<ColumnSettings>

<ig:EditingColumnSetting ColumnKey="Item" ReadOnly="true" />
</ColumnSettings>

</ig:CellEditing>
</Behaviors>
</ig:EditingCore>--%>
</Behaviors>
</ig:WebHierarchicalDataGrid>

Parents
  • 1320
    Offline posted

    Hello Muhammad, 

    After investigating this further, I determined that your requirement could be achieved by looping through all rows and cells of the WebHierarchicalDataGrid and change the text of the cells with the specified key. The text of all cells with key “Data” could be changed as follows:

    protected void ChangeDataCellText(object sender, EventArgs e)

        {

            for(int i = 0; i < WebHierarchicalDataGrid1.Rows.Count; i++)

            {

                for(int j = 0; j < WebHierarchicalDataGrid1.Rows[i].Items.Count; j++)

                {

                    if(WebHierarchicalDataGrid1.Rows[i].Items[j].Column.Key == "Data")

                    {

                        WebHierarchicalDataGrid1.Rows[i].Items[j].Text = "New Value" + i;

                    }

                }         

            }

        }

    Below I am attaching a sample, demonstrating the described behavior. Please test it on your side and let me know if you need any further information regarding this matter.

    Regards,

    Monika Kirkova,

    Infragistics

    WebHierarchicalDataGridChangeCellText.zip

Reply Children