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
650
How to get an ID of a selected Row in a Ultrawebgrid
posted

Good Morning All

i have a Ultrawebgrid defined like this




<igtbl:UltraWebGrid ID="ultraGridStudentsMixTypes" runat="server"
                                    Style="left: -8px; top: 375px" OnInitializeLayout="ultraGridStudentsMixTypes_InitializeLayout" OnDataBound="ultraGridStudentsMixTypes_DataBound" OnSelectedRowsChange="ultraGridStudentsMixTypes_SelectedRowsChange">
                                        <Bands>
                                            <igtbl:UltraGridBand>
                                                <RowEditTemplate>
                                                    <br />
                                                    <p align="center">
                                                        <input id="igtbl_reOkBtn" onclick="igtbl_gRowEditButtonClick(event);" style="width: 50px"
                                                        type="button" value="OK" />&nbsp;
                                                        <input id="igtbl_reCancelBtn" onclick="igtbl_gRowEditButtonClick(event);" style="width: 50px"
                                                        type="button" value="Cancel" /></p>
                                                </RowEditTemplate>
                                                <RowTemplateStyle BackColor="Window" BorderColor="Window" BorderStyle="Ridge">
                                                    <BorderDetails WidthBottom="3px" WidthLeft="3px" WidthRight="3px" WidthTop="3px" />
                                                </RowTemplateStyle>
                                                <AddNewRow View="NotSet" Visible="NotSet">
                                                </AddNewRow>
                                                <Columns>
                                                <igtbl:UltraGridColumn AllowUpdate="No" BaseColumnName="ID" DataType="System.Int32"
                                                    Hidden="True" IsBound="True" Key="ID">
                                                    <Header Caption="ID">
                                                    </Header>
                                                </igtbl:UltraGridColumn>
                                                <igtbl:UltraGridColumn AllowUpdate="No" BaseColumnName="Subject" IsBound="True" Key="Subject">
                                                    <Header Caption="Subject">
                                                        <RowLayoutColumnInfo OriginX="1" />
                                                    </Header>
                                                    <Footer>
                                                        <RowLayoutColumnInfo OriginX="1" />
                                                    </Footer>
                                                </igtbl:UltraGridColumn>
                                                <igtbl:UltraGridColumn AllowUpdate="No" BaseColumnName="Activity" IsBound="True"
                                                    Key="Activity">
                                                    <Header Caption="Activity">
                                                        <RowLayoutColumnInfo OriginX="2" />
                                                    </Header>
                                                    <Footer>
                                                        <RowLayoutColumnInfo OriginX="2" />
                                                    </Footer>
                                                </igtbl:UltraGridColumn>
                                                <igtbl:UltraGridColumn AllowUpdate="Yes" BaseColumnName="Length" DataType="System.Int32"
                                                    IsBound="True" Key="Length">
                                                    <Header Caption="Length">
                                                        <RowLayoutColumnInfo OriginX="3" />
                                                    </Header>
                                                    <Footer>
                                                        <RowLayoutColumnInfo OriginX="3" />
                                                    </Footer>
                                                </igtbl:UltraGridColumn>
                                                  <igtbl:UltraGridColumn AllowUpdate="Yes" BaseColumnName="Mix" DataType="System.Int32"
                                                    IsBound="True" Key="Mix">
                                                    <Header Caption="Mix">
                                                        <RowLayoutColumnInfo OriginX="4" />
                                                    </Header>
                                                    <Footer>
                                                        <RowLayoutColumnInfo OriginX="4" />
                                                    </Footer>
                                                </igtbl:UltraGridColumn>
                                            </Columns>
                                            </igtbl:UltraGridBand>
                                        </Bands>
                                        <DisplayLayout Version="4.00" AllowSortingDefault="OnClient" StationaryMargins="Header"
                                        AllowColSizingDefault="Free" StationaryMarginsOutlookGroupBy="True"
                                        HeaderClickActionDefault="SortSingle" Name="ultraGridStudentsMixTypes" BorderCollapseDefault="Separate"
                                        TableLayout="Fixed" RowHeightDefault="20px" SelectTypeRowDefault="Extended" CellClickActionDefault="RowSelect" EnableInternalRowsManagement="True" SelectTypeCellDefault="Extended" SelectTypeColDefault="Extended">
                                            <FrameStyle BorderWidth="1px" BorderColor="InactiveCaption" BorderStyle="Solid" Font-Size="10pt"
                                            Font-Names="Verdana" BackColor="Window">
                                            </FrameStyle>
                                            <Pager MinimumPagesForDisplay="2" PagerAppearance="Both" PageSize="30" StyleMode="ComboBox"
                                            AllowPaging="True" AllowCustomPaging="True">
                                                <PagerStyle BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">
                                                    <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" />
                                                </PagerStyle>
                                            </Pager>
                                            <EditCellStyleDefault BorderWidth="0px" BorderStyle="None" Font-Names="Verdana" Font-Size="8pt">
                                            </EditCellStyleDefault>
                                            <FooterStyleDefault BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">
                                                <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" />
                                            </FooterStyleDefault>
                                            <HeaderStyleDefault HorizontalAlign="Left" BorderStyle="Solid" BackColor="LightGray"
                                            Font-Bold="True" Font-Names="Verdana" Font-Size="10pt">
                                                <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" />
                                            </HeaderStyleDefault>
                                            <RowStyleDefault BorderWidth="1px" BorderColor="Silver" BorderStyle="Solid" Font-Size="8pt"
                                            Font-Names="Verdana" BackColor="Window">
                                                <Padding Left="3px" />
                                                <BorderDetails ColorLeft="Window" ColorTop="Window" />
                                            </RowStyleDefault>
                                            <GroupByRowStyleDefault BorderColor="Window" BackColor="Control">
                                            </GroupByRowStyleDefault>
                                            <SelectedRowStyleDefault BackColor="Silver" Font-Names="Verdana" Font-Size="8pt">
                                            </SelectedRowStyleDefault>
                                            <GroupByBox>
                                                <BoxStyle BorderColor="Window" BackColor="ActiveBorder">
                                                </BoxStyle>
                                            </GroupByBox>
                                            <AddNewBox>
                                                <BoxStyle BorderWidth="1px" BorderColor="InactiveCaption" BorderStyle="Solid" BackColor="Window">
                                                    <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" />
                                                </BoxStyle>
                                            </AddNewBox>
                                            <ActivationObject BorderWidth="" BorderColor="">
                                            </ActivationObject>
                                            <FilterOptionsDefault>
                                                <FilterDropDownStyle BorderWidth="1px" BorderColor="Silver" BorderStyle="Solid" Font-Size="11px"
                                                Font-Names="Verdana,Arial,Helvetica,sans-serif" BackColor="White" Width="200px"
                                                Height="300px" CustomRules="overflow:auto;">
                                                    <Padding Left="2px" />
                                                </FilterDropDownStyle>
                                                <FilterHighlightRowStyle ForeColor="White" BackColor="#151C55">
                                                </FilterHighlightRowStyle>
                                                <FilterOperandDropDownStyle BorderWidth="1px" BorderColor="Silver" BorderStyle="Solid"
                                                Font-Size="11px" Font-Names="Verdana,Arial,Helvetica,sans-serif" BackColor="White"
                                                CustomRules="overflow:auto;">
                                                    <Padding Left="2px" />
                                                </FilterOperandDropDownStyle>
                                            </FilterOptionsDefault>
                                        </DisplayLayout>
                                    </igtbl:UltraWebGrid>



and i have the Following Code in the SelectedRowsChange event to get the Id of the selected Rows.



protected void ultraGridStudentsMixTypes_SelectedRowsChange(object sender, SelectedRowsEventArgs e)
    {
        SelectedRowsCollection rows = ultraGridStudentsMixTypes.DisplayLayout.SelectedRows;

        string ids = string.Empty;

        foreach (UltraGridRow Rows in rows)
        {
            ids += Rows.Cells.FromKey("ID").Value.ToString() + ", ";

        }

        char[] chars = { ',', ' ' };

        Session["Selected_Rows"] = ids.TrimEnd(chars);
    }



Now  the code inside the Foreach does not run. What i want is to get the ID of the selected Row in the Grid.

Am using Infragisticts 8.1

Thank you