dúvida asp.net c#

jigoro

Power Member
tenho este codigo:
Código:
[SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200]
[/COLOR][/SIZE][/COLOR][/SIZE][B][SIZE=2][COLOR=#eaeaac][SIZE=2][COLOR=#eaeaac][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200][/COLOR][/SIZE][/COLOR][/SIZE][B][SIZE=2][COLOR=#eaeaac][SIZE=2][COLOR=#eaeaac]protected[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200] [/COLOR][/SIZE][/COLOR][/SIZE][B][SIZE=2][COLOR=#eaeaac][SIZE=2][COLOR=#eaeaac]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200] [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#f8ffc6][SIZE=2][COLOR=#f8ffc6]Page_Load[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200]([/COLOR][/SIZE][/COLOR][/SIZE][B][SIZE=2][COLOR=#eaeaac][SIZE=2][COLOR=#eaeaac]object[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200] [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#f8ffc6][SIZE=2][COLOR=#f8ffc6]sender[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200], [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#f0dfaf][SIZE=2][COLOR=#f0dfaf]EventArgs[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200] [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#f8ffc6][SIZE=2][COLOR=#f8ffc6]e[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200])
[/COLOR][/SIZE][/COLOR][/SIZE][/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200]{
[/COLOR][/SIZE][/COLOR][/SIZE][B][SIZE=2][COLOR=#eaeaac][SIZE=2][COLOR=#eaeaac]if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200] ([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#f8ffc6][SIZE=2][COLOR=#f8ffc6]GridViewFinanceiro[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200].[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#f8ffc6][SIZE=2][COLOR=#f8ffc6]SelectedRow[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200].[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#f8ffc6][SIZE=2][COLOR=#f8ffc6]Cells[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200][[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#8acccf][SIZE=2][COLOR=#8acccf]4[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200]].[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#f8ffc6][SIZE=2][COLOR=#f8ffc6]Text[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200] == [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#c89191][SIZE=2][COLOR=#c89191]"Factura"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200])
{
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#f8ffc6][SIZE=2][COLOR=#f8ffc6]GridViewFinanceiro[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200].[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#f8ffc6][SIZE=2][COLOR=#f8ffc6]SelectedRow[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200].[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#f8ffc6][SIZE=2][COLOR=#f8ffc6]Cells[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200][[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#8acccf][SIZE=2][COLOR=#8acccf]5[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200]].[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#f8ffc6][SIZE=2][COLOR=#f8ffc6]Text[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200] = [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#c89191][SIZE=2][COLOR=#c89191]""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#d2d200][SIZE=2][COLOR=#d2d200];
}
}
[/COLOR][/SIZE][/COLOR][/SIZE]

eu quero fazer o seguinte:
A tabela ao ser carregada, coloque a coluna 5 sem dados se, na coluna 4 aparecer a palavra Factura.

Dá erro a dizer que o objecto não têm instancia..
 
penso que esse verificação é melhor ou pores no evento grv_databound, ou grvrowcreated, já não me lembro qual agora

e tem de ser feito um for ou um for each a grid

senão ele não sabe em que linha está
 
Código:
 foreach (GridViewRow row in GridViewFinanceiro.Rows)
                        {

                        
                          
                            int linha = GridViewFinanceiro.RowIndex;

if (GridViewFinanceiro.SelectedRow.Cells[4].Text == "Factura")
{
GridViewFinanceiro.rows[linha]Cells[5].Text = "";
}


                
                        }


tens de fazer uma coisa desse genero
 
Usa o evento ItemDataBound (ou algo parecido), em que cada vez que ele cria a row com dados, faz o que colocares dentro do evento. Atenção que as rows de header e footer também contam ;)
 
Olha estive a ver e podes fazer o que queres ao ao nivel do template do gridview ou atraves do evento databound como foi exemplificado anteriormente.
Se quiseres fazer ao nivel do template basta criares um TemplateField no gridview para o que tu queres e colocares um codigo tipo o apresentado a seguir, mas claro, adaptado ao teu caso.

Código:
<%# (((MVirtual.TestItems)Container.DataItem).Tipo != "Factura") ?
        ((MVirtual.TestItems)Container.DataItem).Preco : 0  
%>

Cumprimentos
 
Back
Topo