Welcome Guest Search | Active Topics | Sign In | Register

Finding the controls in the EO.Web.Grid Options
Raghav Nayak
Posted: Monday, August 25, 2008 10:06:53 PM
Rank: Advanced Member
Groups: Member

Joined: 8/21/2008
Posts: 37
Hi,

I'm using the grid and I want the selected date in the datetime column. I'm getting the selected date of the first row. But rest of the rows the date will be same as the first row. So datetime column will take the date selected in first row. It'll not pick the dates selected in 2nd, 3rd etc..
Also if any of the column is left blank and saved. It'll throw "Object reference not set...." error.

Below is the code. Please check whether I'm doing it properly.

Thanks in advance.

Regards,
Raghav

Code: HTML/ASPX
<eo:Grid ID="Grid1" runat="server" AllowColumnReorder="True" AllowNewItem="True" BorderColor="#7F9DB9" BorderWidth="0px" ColumnHeaderAscImage="00050104"
                                ColumnHeaderDescImage="00050105" ColumnHeaderDividerImage="00050103" FixedColumnCount="1" Font-Names="Tahoma" Font-Size="8.75pt"
                                FullRowMode="False" GoToBoxVisible="True" GridLineColor="220, 223, 228" GridLines="Both" Height="180px" IsCallbackByMe="false"
                                Width="99%" Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False">                                         
                                <FooterStyle CssText="padding-bottom:4px;padding-left:4px;padding-right:4px;padding-top:4px;" />
                                <ItemStyles>
                                    <eo:GridItemStyleSet>
                                        <CellStyle CssText="padding-left:8px;padding-top:2px;" />
                                        <FixedColumnCellStyle CssText="border-right: #d6d2c2 1px solid; padding-right: 10px; border-top: #faf9f4 1px solid; border-left: #faf9f4 1px solid; border-bottom: #d6d2c2 1px solid; background-color: #ebeadb; text-align: right" />
                                    </eo:GridItemStyleSet>
                                </ItemStyles>
                                <GoToBoxStyle CssText="BORDER-RIGHT: #7f9db9 1px solid; BORDER-TOP: #7f9db9 1px solid; BORDER-LEFT: #7f9db9 1px solid; WIDTH: 40px; BORDER-BOTTOM: #7f9db9 1px solid" />
                                <ContentPaneStyle CssText="border-bottom-color:#7f9db9;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#7f9db9;border-left-style:solid;border-left-width:1px;border-right-color:#7f9db9;border-right-style:solid;border-right-width:1px;border-top-color:#7f9db9;border-top-style:solid;border-top-width:1px;" />
                                <ColumnTemplates>
                                    <eo:TextBoxColumn>
                                        <TextBoxStyle CssText="BORDER-RIGHT: #7f9db9 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #7f9db9 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 8.75pt; PADDING-BOTTOM: 1px; MARGIN: 0px; BORDER-LEFT: #7f9db9 1px solid; PADDING-TOP: 2px; BORDER-BOTTOM: #7f9db9 1px solid; FONT-FAMILY: Tahoma" />
                                    </eo:TextBoxColumn>
                                </ColumnTemplates>
                                <Columns>                                    
                                    <eo:RowNumberColumn Width="40">
                                    </eo:RowNumberColumn>
                                    <eo:TextBoxColumn DataField="FirstName" HeaderText="First Name" Width="125">
                                    </eo:TextBoxColumn>
                                    <eo:TextBoxColumn DataField="MiddleName" HeaderText="Middle Name" Width="125">
                                    </eo:TextBoxColumn>
                                    <eo:TextBoxColumn DataField="LastName" HeaderText="Last Name" Width="125">
                                    </eo:TextBoxColumn>
                                    <eo:DateTimeColumn DataField="DateOfBirth2" HeaderText="Date of Birth">
                                        <DatePicker ID="dsChildrenDOB" ControlSkinID="None" DayCellHeight="16" DayCellWidth="19" DayHeaderFormat="FirstLetter" DisabledDates="" OtherMonthDayVisible="True"
                                            PickerFormat="dd/MM/yyyy" SelectedDates="" TitleLeftArrowImageUrl="DefaultSubMenuIconRTL" TitleRightArrowImageUrl="DefaultSubMenuIcon">
                                            <TodayStyle CssText="font-family: tahoma; font-size: 12px; border-right: #bb5503 1px solid; border-top: #bb5503 1px solid; border-left: #bb5503 1px solid; border-bottom: #bb5503 1px solid" />
                                            <PickerStyle CssText="font-family:Courier New; padding-left:5px; padding-right: 5px;" />
                                            <SelectedDayStyle CssText="font-family: tahoma; font-size: 12px; background-color: #fbe694; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
                                            <DisabledDayStyle CssText="font-family: tahoma; font-size: 12px; color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
                                            <CalendarStyle CssText="background-color: white; border-right: #7f9db9 1px solid; padding-right: 4px; border-top: #7f9db9 1px solid; padding-left: 4px; font-size: 9px; padding-bottom: 4px; border-left: #7f9db9 1px solid; padding-top: 4px; border-bottom: #7f9db9 1px solid; font-family: tahoma" />
                                            <TitleArrowStyle CssText="cursor:hand" />
                                            <DayHoverStyle CssText="font-family: tahoma; font-size: 12px; border-right: #fbe694 1px solid; border-top: #fbe694 1px solid; border-left: #fbe694 1px solid; border-bottom: #fbe694 1px solid" />
                                            <MonthStyle CssText="font-family: tahoma; font-size: 12px; margin-left: 14px; cursor: hand; margin-right: 14px" />
                                            <TitleStyle CssText="background-color:#9ebef5;font-family:Tahoma;font-size:12px;padding-bottom:2px;padding-left:6px;padding-right:6px;padding-top:2px;" />
                                            <OtherMonthDayStyle CssText="font-family: tahoma; font-size: 12px; color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
                                            <DayHeaderStyle CssText="font-family: tahoma; font-size: 12px; border-bottom: #aca899 1px solid" />
                                            <DayStyle CssText="font-family: tahoma; font-size: 12px; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
                                        </DatePicker>
                                    </eo:DateTimeColumn>
                                    <eo:CustomColumn ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit" DataField="RelationshipTypes" HeaderText="Relation">
                                        <EditorTemplate>
                                            <select id="ddlRelationshipType">
                                                <option value="0">--- Select ---</option>
                                                <option value="12">SON</option>
                                                <option value="13">DAUGHTER</option>
                                            </select>
                                        </EditorTemplate>
                                    </eo:CustomColumn>
                                    <eo:TextBoxColumn DataField="School" HeaderText="School name &amp; Address" Width="165">
                                    </eo:TextBoxColumn>
                                    <eo:CheckBoxColumn DataField="IsLivingAtHome" HeaderText="Child at Home">
                                    </eo:CheckBoxColumn>
                                    <eo:StaticColumn DataField="ID" Width="0">
                                    </eo:StaticColumn>
                                </Columns>
                                <ColumnHeaderStyle CssText="background-image:url('00050101');padding-left:8px;padding-top:3px;" />
                            </eo:Grid>



Code: C#
foreach (EO.Web.GridItem item in Grid1.Items)
                {
                    if (item.Cells[1].Value == null) item.Cells[1].Value = string.Empty;
                    if (item.Cells[2].Value == null) item.Cells[2].Value = string.Empty;
                    if (item.Cells[3].Value == null) item.Cells[3].Value = string.Empty;
                    if (item.Cells[4].Value == null) item.Cells[4].Value = string.Empty;
                    if (item.Cells[5].Value == null) item.Cells[5].Value = string.Empty;
                    if (item.Cells[6].Value == null) item.Cells[6].Value = string.Empty;
                    if (item.Cells[7].Value == null) item.Cells[7].Value = "false";

                    if ((item.Cells[1].Value.ToString().Trim() != "") && (item.Cells[1].Value.ToString() != String.Empty))
                    {
                        EO.Web.DateTimeColumn column = (EO.Web.DateTimeColumn)Grid1.Columns[4];
                        EO.Web.DatePicker objDatePicker = (EO.Web.DatePicker)column.DatePicker.FindControl("dsChildrenDOB");

                        carerFamilyData = new CarerFamilyDTO();

                        carerFamilyData.FirstName = item.Cells[1].Value.ToString();
                        carerFamilyData.MiddleName = item.Cells[2].Value.ToString();
                        carerFamilyData.LastName = item.Cells[3].Value.ToString();
                        carerFamilyData.DateOfBirth = objDatePicker.SelectedDate.ToShortDateString();
                        if (item.Cells[5].Value.ToString() == "SON")
                            carerFamilyData.RelationshipTypesID = 12;
                        else if (item.Cells[5].Value.ToString() == "DAUGHTER")
                            carerFamilyData.RelationshipTypesID = 13;
                        else
                            carerFamilyData.RelationshipTypesID = 0;
                        carerFamilyData.School = item.Cells[6].Value.ToString();
                        carerFamilyData.IsLivingAtHome = Convert.ToBoolean(item.Cells[7].Value) ? true : false;
                        if (item.Cells[8].Value != null) carerFamilyData.ID = int.Parse(item.Cells[8].Value.ToString());
                        else carerFamilyData.ID = 0;

                        familyList.Add(carerFamilyData);
                    }                    
                }
eo_support
Posted: Tuesday, August 26, 2008 7:01:03 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,193
Hi,

Most of your code looks fine to us except that I am not sure why you would want to use FindControl to find the DatePicker control. As you are already aware of, all the values for a cell should be accessed by item.Cells[i].Value, even if you only care about the value of the first row.

The DatePicker is a control maintained by the GridColumn but shared by all items, the control is exposed only for you to configure the DatePicker, not for setting/getting the cell value because usually each cell has a different value.

Hope this helps.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.