How to get an ID of a selected Row in a Ultrawebgrid

Last post 07-08-2009 2:44 AM by Vuyiswamb. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 06-25-2009 2:21 AM

    • Vuyiswamb
    • Top 100 Contributor
    • Joined on 05-22-2009
    • South Africa
    • Wannabe Slacker
    • Points 90

    How to get an ID of a selected Row in a Ultrawebgrid

    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

    www.itsabacus.co.za
    Experts in University Timetabling
  •  Advertisement

    Featured Advertisement

     
  • 07-08-2009 12:26 AM In reply to

    Re: How to get an ID of a selected Row in a Ultrawebgrid

    i would suggest you to also post your query on ingragistics forums here > http://forums.infragistics.com/aspnet/forums/default.aspx

    "I would love to change the world, but they won’t give me the source code"

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point & mark your thread as Resolved for the sake of Future Readers.

    KaushaL || BLOG || Profile || Microsoft MVP
  • 07-08-2009 2:44 AM In reply to

    • Vuyiswamb
    • Top 100 Contributor
    • Joined on 05-22-2009
    • South Africa
    • Wannabe Slacker
    • Points 90

    Re: How to get an ID of a selected Row in a Ultrawebgrid

     Thank you. i have posted that in the Forum , but the reply after some time, so i have found a solution to some people in other forums that happen to use infragistics.

    Solution:

    i used a clientside scriping to find the ID of the row like this

     

     

     

     

     

     

     

     

     

     

     

    function

    SetHidSelectedRows()

    {

     

     

    var grid = igtbl_getGridById("<%= Gridstaff.ClientID %>"

    );

     

     

    var HidActivity = document.getElementById("<%= HidSelectedActv.ClientID %>"

    );

     

     

    var HidSelecteStaff = document.getElementById("<%= HidSelecteStaff.ClientID %>"

    );

     

     

    var selectedActivity = new

    Array();

     

     

    var selectedStaff = new

    Array();

     

     

     

    for(var rowId in

    grid.SelectedRows)

    {

     

     

    var

    row=igtbl_getRowById(rowId);

    selectedActivity.push(row.getCell(0).getValue());

     

    selectedStaff.push(row.getCell(1).getValue());

     

    }

     

    HidActivity.value = selectedActivity;

     

    HidSelecteStaff.value = selectedStaff;

     

     

     

    return true;

     

    and i have created two hidden Fields and retrieve the values on the server side.

     

    Thanks

    www.itsabacus.co.za
    Experts in University Timetabling
Page 1 of 1 (3 items)