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
webdatechooser inside webgrid
posted

hi ,

I have problem when creating webdate chooser inside webgrid.i am not getting the webdatechooser while editing webgrid.Here I provide my design and code behind code.Plz help me..

Thanks in Advance,

Reagan.J


<div>
<igtbl:UltraWebGrid style="LEFT: 67px; TOP: 0px" id="grid" tabIndex=1 InitializeLayout="grid_InitializeLayout" InitializeDataSource="grid_InitializeDataSource" runat="server" Browser="Xml" Width="100%" Height="160px" __designer:wfdid="w3">
                                                <Bands>
                                                    <igtbl:UltraGridBand AllowSorting="No">
                                                        <AddNewRow View="NotSet" Visible="NotSet">
                                                        </AddNewRow>
                                                    </igtbl:UltraGridBand> 
                                                </Bands>
                                               
                                                <DisplayLayout ScrollBarView="Vertical" AllowColSizingDefault="Free" AllowColumnMovingDefault="OnServer"
                                                    AllowDeleteDefault="Yes" BorderCollapseDefault="Separate" HeaderClickActionDefault="SortMulti"
                                                    Name="grid" RowHeightDefault="20px" RowSelectorsDefault="No" SelectTypeRowDefault="Extended"
                                                    StationaryMargins="Header" StationaryMarginsOutlookGroupBy="True" TableLayout="Fixed"
                                                    Version="4.00" LoadOnDemand="Xml">
                                                    <GroupByBox>
                                                        <BoxStyle BackColor="ActiveBorder" BorderColor="Window">
                                                        </BoxStyle>
                                                    </GroupByBox>
                                                    <GroupByRowStyleDefault BackColor="Control" BorderColor="Window">
                                                    </GroupByRowStyleDefault>
                                                    <ActivationObject BorderColor="" BorderWidth="">
                                                    </ActivationObject>
                                                    <FooterStyleDefault BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px">
                                                        <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" />
                                                    </FooterStyleDefault>
                                                    <RowStyleDefault BackColor="Window" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px"
                                                        Font-Names="Microsoft Sans Serif" Font-Size="8.25pt">
                                                        <BorderDetails ColorLeft="Window" ColorTop="Window" />
                                                        <Padding Left="3px" />
                                                    </RowStyleDefault>
                                                    <FilterOptionsDefault>
                                                        <FilterOperandDropDownStyle BackColor="White" BorderColor="Silver" BorderStyle="Solid"
                                                            BorderWidth="1px" CustomRules="overflow:auto;" Font-Names="Verdana,Arial,Helvetica,sans-serif"
                                                            Font-Size="11px">
                                                            <Padding Left="2px" />
                                                        </FilterOperandDropDownStyle>
                                                        <FilterHighlightRowStyle BackColor="#151C55" ForeColor="White">
                                                        </FilterHighlightRowStyle>
                                                        <FilterDropDownStyle BackColor="White" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px"
                                                            CustomRules="overflow:auto;" Font-Names="Verdana,Arial,Helvetica,sans-serif"
                                                            Font-Size="11px" Height="160px" Width="200px">
                                                            <Padding Left="2px" />
                                                        </FilterDropDownStyle>
                                                    </FilterOptionsDefault>
                                                    <HeaderStyleDefault BackColor="#8CAED0" BorderStyle="Solid" HorizontalAlign="Left"
                                                        Font-Names="Arial" Font-Size="Small">
                                                        <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" />
                                                    </HeaderStyleDefault>
                                                    <EditCellStyleDefault BorderStyle="None" BorderWidth="0px">
                                                    </EditCellStyleDefault>
                                                    <FrameStyle Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Height="150px" Width="100%"
                                                        BackColor="White">
                                                    </FrameStyle>
                                                    <AddNewBox Hidden="False">
                                                        <BoxStyle BackColor="Window" BorderColor="InactiveCaption" BorderStyle="Solid" BorderWidth="1px">
                                                        </BoxStyle>
                                                    </AddNewBox>
                                                    <FixedHeaderStyleDefault BackColor="#8CAED0">
                                                    </FixedHeaderStyleDefault>
                                                   
                                                </DisplayLayout>
                                               
                                            </igtbl:UltraWebGrid> </div>
<igsch:WebDateChooser id="fromDate" runat="server" Width="200px" Height="150px" Font-Size="8pt"
     Font-Names="Verdana">
   </igsch:WebDateChooser>


code behind code:::


    private void grid_InitializeDataSource(object sender,Infragistics.WebUI.UltraWebGrid.UltraGridEventArgs e)
    {
        try
        {
            LoadGrid();
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
   
 
    private void grid_InitializeLayout(object sender,Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e)
    {
        try
        {
            this.grid.DisplayLayout.AllowColumnMovingDefault = AllowColumnMoving.None;
            this.grid.DisplayLayout.AllowColSizingDefault = AllowSizing.Fixed;
            this.grid.DisplayLayout.AllowSortingDefault = AllowSorting.No;
            this.grid.DisplayLayout.CellClickActionDefault = CellClickAction.RowSelect;
            this.grid.DisplayLayout.AllowColumnMovingDefault = AllowColumnMoving.None;
            this.grid.DisplayLayout.SelectTypeRowDefault = SelectType.Single;
            this.grid.Bands[0].AllowColSizing = Infragistics.WebUI.UltraWebGrid.AllowSizing.Fixed;
            this.grid.Width = Unit.Percentage(100);

            grid.Bands[0].Columns.Clear();
            UltraGridColumn GridColumn;

            GridColumn = new UltraGridColumn();
            GridColumn.BaseColumnName = "Id";
            GridColumn.Key = "UserRoleId";
            grid.Bands[0].Columns.Add(GridColumn);
            GridColumn.Header.RowLayoutColumnInfo.OriginY = 0;
            GridColumn.Width = 1;
            GridColumn.Hidden = true;

            GridColumn = new UltraGridColumn();
            GridColumn.BaseColumnName = "A";
            GridColumn.Key = "Id";
            GridColumn.Header.Caption = "A";
            GridColumn.Header.RowLayoutColumnInfo.OriginY = 0;
            GridColumn.Width = Unit.Percentage(25);
            GridColumn.Type = ColumnType.DropDownList;
            grid.Bands[0].Columns.Add(GridColumn);
            //Load the column
            ValueList AList = new ValueList();
            DataTable ds  = new DataTable();
            ds  = Value From DB;
            int rowCount = ds.Rows.Count;
            for (int j = 0; j < rowCount; j++)
            {  
                AList.ValueListItems.Add(ds.Rows[j]["Id"].ToString(),ds.Rows[j]["A"].ToString());
            }
            grid.Columns[1].ValueList = AList;

            GridColumn = new UltraGridColumn();
            GridColumn.BaseColumnName = "B";
            GridColumn.Key = "Id";
            GridColumn.Header.Caption = "B";
            GridColumn.Header.RowLayoutColumnInfo.OriginY = 0;
            GridColumn.Width = Unit.Percentage(25);
            GridColumn.Type = ColumnType.DropDownList;
            grid.Bands[0].Columns.Add(GridColumn);
            //Load the column
            ValueList BList = new ValueList();
            DataTable ds1 = new DataTable();
            ds1 =Value From DB;
            int rowCount  = ds1.Rows.Count;
            for (int j = 0; j < rowCount ; j++)
            {
              RoleNameList.ValueListItems.Add(ds1.Rows[j]["Id"].ToString(), ds1.Rows[j]["B"].ToString());
            }
            grid.Columns[2].ValueList = BList;

           

            GridColumn = new UltraGridColumn();
            GridColumn.BaseColumnName = "FromDate";
            GridColumn.Header.Caption = "From Date";
            GridColumn.Header.RowLayoutColumnInfo.OriginY = 0;
            GridColumn.Width = Unit.Percentage(25);
            GridColumn.Key = "FromDate";
            grid.Bands[0].Columns.Add(GridColumn);
            grid.DisplayLayout.AllowUpdateDefault = AllowUpdate.Yes;
            grid.DisplayLayout.Bands[0].Columns[3].EditorControlID = fromDate.UniqueID;
            grid.DisplayLayout.Bands[0].Columns[3].Type = ColumnType.Custom;
            fromDate.DropDownStyle.BackColor = System.Drawing.Color.Blue;
            GridColumn.DataType = "System.DateTime";
            fromDate.Format = Infragistics.WebUI.WebSchedule.DateFormat.Short;

            GridColumn = new UltraGridColumn();
            GridColumn.BaseColumnName = "ToDate";
            GridColumn.Header.Caption =  "To Date";
            GridColumn.Header.RowLayoutColumnInfo.OriginY = 0;
            GridColumn.Width = Unit.Percentage(25);
            GridColumn.Key = "ToDate";
            grid.Bands[0].Columns.Add(GridColumn);
            GridColumn.Type = ColumnType.Custom;
            GridColumn.EditorControlID = toDate.ID;
            GridColumn.Width = Unit.Percentage(23);
            GridColumn.FieldLen = 10;
            GridColumn.AllowUpdate = AllowUpdate.Yes;
            GridColumn.HTMLEncodeContent = true;

            GridColumn = new UltraGridColumn();           
            GridColumn.Key = "Status";
            grid.Bands[0].Columns.Add(GridColumn);
            GridColumn.Header.RowLayoutColumnInfo.OriginY = 0;
            GridColumn.Width = 1;
            GridColumn.Hidden = true;

            // set the DataKeyField for the band
            e.Layout.Bands[0].DataKeyField = "Id";

            // turn on paging
            e.Layout.Pager.AllowPaging = false;
        }
        catch (Exception ex)
        {
             throw ex;
        }
    }
  

 


 private void LoadGrid()
    {
        try
        {
            // Clear rows in grid
            grid.Rows.Clear();
            DataSet ds = new DataSet();
            try
            {
                
                ds= Value from DB;
               
            }
            catch (Exception)
            {
                throw new Exception("NoRecord"));
            }
            // Clear columns in grid
            grid.Columns.Clear();
            if (ds.Tables[0].Rows.Count == 0)
            {
                // Add empty column header
                grid.Columns.Add("id");
                grid.Columns.Add("A");
                grid.Columns.Add("RoleName");
                grid.Columns.Add("FromDate");
                grid.Columns.Add("ToDate);
                grid.Columns[0].Hidden = true;
                return;
            }
            else
            {
                // Clear columns in grid
                grid.Columns.Clear();
                grid.DataSource = ds.Tables[0];
                grid.DataBind();
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

Parents
No Data
Reply Children
No Data