How to debug to know which database or table are running with Asp.Net

Asked

Viewed 116 times

2

I’m 10 days into my new job, and I’m having some difficulties - which is normal, depending on the difficulty.

I have a Table inside a Repeater, which is powered by a Procedure.

Like I do with Debug, to find the Procedure running through that line?

<asp:HiddenField ID="hdfCdTipoUsuario" runat="server" Value='<%# Eval("CdTipoUsuario")%>' />

That’s all the Peater and the table:

<asp:Repeater ID="rptGerenciaProcessos" runat="server" 
    onitemcommand="rptGerenciaProcessos_ItemCommand" 
    onitemdatabound="rptGerenciaProcessos_ItemDataBound">
    <HeaderTemplate>
    <table id="gerenciaProcessos">
    <thead>
        <tr>
            <th>Consultar processo</th>
            <th>Priorizar</th>
            <th>Priorizado</th>
            <th>Nº do processo</th>
            <th>Data de abertura</th>
            <th>Início da análise</th>
            <th>Término na análise</th>
            <th>Situação</th>
            <th>Grupo</th>
            <th>Cota</th>
            <th>Etapa</th>
            <th>Analista</th>
        </tr>
    </thead>
    </HeaderTemplate>
    <ItemTemplate>
        <tr>
            <td>
                <asp:Button ID="btnConsultarProcessos" OnClick="btnConsultarProcessos_Click" runat="server" Text="Consultar processo" CommandName="ConsultaProcessoGestor" CssClass="acessos" />
            </td>
            <td>
                <asp:HiddenField ID="hdfCdProcesso" runat="server" Value='<%# Eval("CdProcesso")%>'/>
                <asp:HiddenField ID="hdfCdAnalise" runat="server" Value='<%# Eval("CdAnalise")%>' />
                <asp:HiddenField ID="hdfCdUsuario" runat="server" Value='<%# Eval("CdUsuarioAn")%>' />
                <asp:HiddenField ID="hdfCdWorkFlowItem" runat="server" Value='<%# Eval("CdWorkFlowItem")%>' />
                <asp:HiddenField ID="hdfCdTipoUsuario" runat="server" Value='<%# Eval("CdTipoUsuario")%>' />
                <asp:LinkButton ID="lkbPriorizar" runat="server" CssClass="clickPriorizar">Priorizar</asp:LinkButton>
                <!--<a href="#"class="clickPriorizar">Priorizar</a>-->
            </td>
            <td><input type="checkbox" id="ckbPriorizado" <%# Eval("IcPriorizado")%> disabled></td>
            <td><asp:Label Text='<%# Eval("CdProcesso")%>'      runat="server" /></td>
            <td><asp:Label Text='<%# Eval("DtCriacao")%>'       runat="server" /></td>
            <td><asp:Label Text='<%# Eval("DtInicio")%>'        runat="server" /></td>
            <td><asp:Label Text='<%# Eval("DtFim")%>'           runat="server" /></td>
            <td><asp:Label Text='<%# Eval("NmWorkFlowItem")%>'  runat="server" /></td>
            <td><asp:Label Text='<%# Eval("CdGrupo")%>'         runat="server" /></td>
            <td><asp:Label Text='<%# Eval("CdCota")%>'          runat="server" /></td>
            <td><asp:Label Text='<%# Eval("NmTipoStatus")%>'    runat="server" /></td>
            <td><asp:Label Text='<%# Eval("NomeUsuario")%>'     runat="server" /></td>
        </tr>
    </ItemTemplate>
    <FooterTemplate>
    </table>
    </FooterTemplate>
</asp:Repeater>

The difficulty is in knowing how I debug the line ...Eval("Meu_Campo")...

2 answers

1

Repeater dynamic content is normally loaded as follows:

rptGerenciaProcessos.DataSource = RetornaDados(parametro1, parametro2);
rptGerenciaProcessos.DataBind();

To know which Procedure is run to power the Repeater, you must walk the path in reverse of what is set from the DataSource.

It may be that the path becomes more complicated if this assignment is not explicit in code-Behind from your page (usually [page name].aspx.Cs). It may be calling a generic function from another place to load the data:

CarregaRepeater(rptGerenciaProcessos, RetornaDados(parametro1, parametro2));

I advise, to look for RetornaDados(parametro1, parametro2)s in the page source code. If not find search for all occurrences of rptGerenciaProcessos. Use the "Find All".

About debugging the Eval("Meu_Campo"):

This code snippet defines that the value in the "Field" column will go in this field of your page, for each Datasource item. You can overwrite this behavior through the event OnItemDataBound:

void rptGerenciaProcessos_ItemDataBound(Object Sender, RepeaterItemEventArgs e) {
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {
        Processo item = (Processo)e.Item.DataItem;
        // Coloque um breakpoint aqui e analise a variável "item"
        if (Item.CdTipoUsuario == 5) {
            ((Label)e.Item.FindControl("hdfCdTipoUsuario")).Value = "50";
        }
    }
}  

0

When you used a page your page.aspx is created the Codebehind of it with name_your_page.Cs is where your Repeater is being loaded. Edit this page . Cs and find rptGerenciaProcessos.Datasource on it will be the contents of the data. It can be loaded by an object or by method execution. In the method that will be the SP name or Sql expression used for the load.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.