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
55
WEbdatagrid v11.1 with a template column checkbox and objectdatasource
posted

Hi, i need your help.

i have got a webdatagrid with a template column with a checkbox.

the grid is loaded by a objectdatasource.

the problem is , when click the checkbox and then press a button on the infragistics webdatamenu, the value checked is always null..

What am i doing wrong?

Here is the code

<ig:WebDataGrid ID="WebDataGridAutAssiduidade" runat="server" width="100%" height="100%"
        autogeneratecolumns="False"    enableviewstate="False" datasourceid="odsAsAutorizacoesAssiduidade"  datakeyfields="ID">
        <emptyrowstemplate>
            Sem registos...</emptyrowstemplate>        
        <columns>     
            <ig:TemplateDataField key="chkBox" width="40px">
                <HeaderTemplate>
                    <asp:CheckBox runat="server" ID="chkAll" CssClass="center" OnClick="SelectAll(this)" />
                </HeaderTemplate>
                <ItemTemplate>
                   <%-- <asp:CheckBox runat="server" ID="chkAsAutAssiduidade" CssClass="center" />--%>
                   <asp:CheckBox ID="CheckBox2" runat="server"   />
                </ItemTemplate>
            </ig:TemplateDataField>
            <ig:BoundDataField DataFieldName="ID" Hidden="True" Key="ID">
                <Header Text="ID" />
            </ig:BoundDataField>     
            <ig:TemplateDataField Key="Validado" Width="135px">
                <ItemTemplate>
                    <img style="float: left" alt='' src='img/autorizar_<%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "Validado","") %>_16.png' />
                    <ig1:WebDropDown ID="WebDropDownVal" runat="server" SelectedValue='<%# Bind("Validado") %>'
                        DisplayMode="ReadOnly" Button-Visible="False" Width="116px" BorderColor="White"
                        BorderStyle="None" BorderWidth="0px" EnableTheming="True" CssClass="noBorder">
                        <Items>
                            <ig1:DropDownItem Value="0" Text="Não autorizado">
                            </ig1:DropDownItem>
                            <ig1:DropDownItem Value="1" Text="Autorizado">
                            </ig1:DropDownItem>
                            <ig1:DropDownItem Value="2" Text="Pendente">
                            </ig1:DropDownItem>
                        </Items>
                        <Button Visible="False" />
                    </ig1:WebDropDown>
                </ItemTemplate>
                <Header Text="Validação final" />
            </ig:TemplateDataField>
            <ig:TemplateDataField Key="Data" Width="90px">
                <ItemTemplate>
                    <asp:Label ID="LabelR1" runat="server" CssClass="cLblL"><%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "DateMov","{0:dd/MM/yyyy ddd}") %></asp:Label>
                </ItemTemplate>
                <Header Text="Data" />
            </ig:TemplateDataField>
            <ig:BoundDataField DataFieldName="PID" Hidden="True" Key="PID">
                <Header Text="PID" />
            </ig:BoundDataField>
            <ig:TemplateDataField Key="PNumero" Width="60px">
                <ItemTemplate>
                    <asp:Label ID="Label1" CssClass="cLblR" Width="50px" runat="server"><%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "PNumero") %></asp:Label>
                </ItemTemplate>
                <Header Text="Número" />
            </ig:TemplateDataField>
            <ig:TemplateDataField CssClass="cLblL" Key="PNome" Width="200px">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server"><%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "PNome") %></asp:Label>
                </ItemTemplate>
                <Header Text="Nome" />
            </ig:TemplateDataField>
            <ig:BoundDataField DataFieldName="Obs" Key="Obs" Width="160px" >
                <Header Text="Observações" />
            </ig:BoundDataField>
            <ig:TemplateDataField Key="DataInicio" Width="40px">
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Width="35px" CssClass="cLblC"><%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "DateMov", "{0:HH:mm}")%></asp:Label>
                </ItemTemplate>
                <Header Text="Hora" />
            </ig:TemplateDataField>
            <ig:TemplateDataField Key="DataValidado" Width="70px">
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" CssClass="cLblC" Width="60px"><%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "DataValidado", "{0:dd/MM/yyyy}")%></asp:Label>
                </ItemTemplate>
                <Header Text="Data validação" />
            </ig:TemplateDataField>
            <ig:BoundDataField DataFieldName="IDValidado" Key="IDValidado" Hidden="true">
                <Header Text="IDValidado" />
            </ig:BoundDataField>
            <ig:TemplateDataField CssClass="cLblL" Key="VNome" Width="240px">
                <ItemTemplate>
                    <asp:Label ID="Label5" runat="server"><%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "VNome") %></asp:Label>
                </ItemTemplate>
                <Header Text="Validado por" />
            </ig:TemplateDataField>
            <ig:TemplateDataField Key="RespValidado" Width="135px">
                <ItemTemplate>
                    <img style="float: left" alt='' src='img/autorizar_<%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "RespValidado","") %>_16.png' />
                    <ig1:WebDropDown ID="WebDropDownRespVal" runat="server" SelectedValue='<%# Bind("RespValidado") %>'
                        DisplayMode="ReadOnly" Button-Visible="False" Width="116px" BorderColor="White"
                        BorderStyle="None" BorderWidth="0px" EnableTheming="True" CssClass="noBorder">
                        <Items>
                            <ig1:DropDownItem Value="0" Text="Não autorizado">
                            </ig1:DropDownItem>
                            <ig1:DropDownItem Value="1" Text="Autorizado">
                            </ig1:DropDownItem>
                            <ig1:DropDownItem Value="2" Text="Pendente">
                            </ig1:DropDownItem>
                        </Items>
                        <Button Visible="False" />
                    </ig1:WebDropDown>
                </ItemTemplate>
                <Header Text="Validação resp." />
            </ig:TemplateDataField>
           <ig:TemplateDataField Key="DataRespValidado" Width="70px">
                <ItemTemplate>
                    <asp:Label ID="Label6" runat="server" CssClass="cLblC" Width="60px"><%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "DataRespValidado", "{0:dd/MM/yyyy}")%></asp:Label>
                </ItemTemplate>
                <Header Text="Data validação do resp." />
            </ig:TemplateDataField>
            <ig:BoundDataField DataFieldName="IDRespValidado" Key="IDRespValidado" Hidden="true">
                <Header Text="IDRespValidado" />
            </ig:BoundDataField>
           <ig:TemplateDataField CssClass="cLblL" Key="RNome" Width="240px">
                <ItemTemplate>
                    <asp:Label ID="Label7" runat="server"><%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "RNome") %></asp:Label>
                </ItemTemplate>
                <Header Text="Validado pelo resp." />
            </ig:TemplateDataField>
        </Columns>
        <Behaviors>
            <ig:Sorting>
              <ColumnSettings>
                            <ig:SortingColumnSetting ColumnKey="Hora" Sortable="false" />
                          
                            <ig:SortingColumnSetting ColumnKey="Obs" Sortable="false" />
                          
                           
                        </ColumnSettings>
            </ig:Sorting>
            <ig:EditingCore>
            </ig:EditingCore>
            <ig:ColumnResizing>
            </ig:ColumnResizing>
           
            <ig:Paging PagerMode="NumericFirstLast" PageSize="60" QuickPages="5">
            </ig:Paging>
            <ig:RowSelectors RowNumbering="True">
            </ig:RowSelectors>
        </Behaviors>
        <AjaxIndicator Enabled="true" />
    </ig:WebDataGrid>
        <asp:ObjectDataSource ID="odsAsAutorizacoesAssiduidade" runat="server"  SelectCountMethod="GetAsAutorizacoesAssiduidadeCount"
        SelectMethod="GetAsAutorizacoesAssiduidade" TypeName="IdOntime.AsAutorizacoesAssiduidade" SortParameterName="sSortColumn"
        MaximumRowsParameterName="maximumRows" StartRowIndexParameterName="startRowIndex"    EnableCaching="False"  EnablePaging="true" OldValuesParameterFormatString="original_{0}">
        <SelectParameters>
            <asp:Parameter Name="maximumRows" Type="Int32" />
        <asp:Parameter Name="startRowIndex" Type="Int32" />
        <asp:Parameter Name="prmDtpInicio" Type="String" />
        <asp:Parameter Name="prmDtpFim" Type="String" />
        <asp:Parameter Name="prmIdSelPessoas" Type="String" />
        <asp:Parameter Name="prmIdDepartamentos" Type="String" />
        <asp:Parameter Name="prmIdGrupos" Type="String" />
        <asp:Parameter Name="prmValidacao" Type="Int16" />
        <asp:Parameter Name="prmRespValidacao" Type="Int16" />               
        </SelectParameters>
  
      
    </asp:ObjectDataSource>

here is waht the web menu does:

 protected void WebDataMenuOptions_ItemClick(object sender, Infragistics.Web.UI.NavigationControls.DataMenuItemEventArgs e)
        {
                 if (e.Item.Key == "btnFAutorizar")
                {
                    ValidarFinal(AutorizarPedido.Autorizado);
                }

}

and here is the function validarfinal

 private void ValidarFinal(AutorizarPedido aut)
        {
            DbMan db = (DbMan)Session["DB"];
            DBManCommandsMovimentos dbcAsMov = new DBManCommandsMovimentos(db);

            foreach (GridRecord row in WebDataGridAutAssiduidade.Rows)
            {
                CheckBox chkSel = row.Items[0].FindControl("CheckBox2") as CheckBox;
                if (chkSel.Checked)
                {
                    int id = Convert.ToInt32(row.Items[WebDataGridAutAssiduidade.Columns["ID"].Index].Value);
                    //a chefia não se pode alterar a ela própria
                    if (Convert.ToInt32(row.Items[WebDataGridAutAssiduidade.Columns["PID"].Index].Value) == (int)Session["IDU"] && !Nulls.GetBool(Session["Admin"]))
                        continue;

                    dbcAsMov.AutorizarAsMovimentos(id, (short)aut, (int)Session["IDU"]);
                }
            }

            db.WriteTStampTable("asMovimentos", DbOperationType.Update);
        }

the problem is the checked value of the checkbox is always null..

thanks for the help..