USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Fórum

  Visual Basic
Voltar
Autor Assunto:  como pegar valor de gridview dentro de controle...
vilmarbr
Pontos: 2843
SAO PAULO
SP - BRASIL
ENUNCIADA !
Postada em 08/03/2012 20:50 hs         
ASP.NET/VB.NET

como pegar valor de gridview dentro de controle linkbutton ou hyperlink?
eles estão dentro do grid, dentro de um template...:

            <asp:TemplateField HeaderText="Atividade" SortExpression="1">
                <ItemTemplate>
                    <asp:LinkButton ID="lb" runat="server" CausesValidation="false" />
                    <asp:HyperLink ID="hl" runat="server">[hl]</asp:HyperLink>                    
                </ItemTemplate>
            </asp:TemplateField>


quero pegar estes valores num loop, já com dados exibidos, mas não vem nada....
WITH MEUGRID
                For m = 0 To .Rows.Count - 1
                    For n = 0 To .Rows.Count - 1
                        Response.Write(.Rows(m).Cells(n).Text & ";")
                    Next

                    Response.Write(Environment.NewLine)
                Next
END WITH
qual o macete??

os dados que não estão dentro destes controles, vem numa boa...

os dados nestes controles são jogados no rowdatabound:


        Protected Sub MEUGRID_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles MEUGRID.RowDataBound
            If Not e.Row.DataItem Is Nothing Then
                If e.Row.RowType = DataControlRowType.DataRow Then
                    Dim dr As System.Data.DataRowView = CType(e.Row.DataItem, System.Data.DataRowView)
                    Dim lb As LinkButton = CType(e.Row.Cells(0).FindControl("lb"), LinkButton)
                    Dim hl As HyperLink = CType(e.Row.Cells(0).FindControl("hl"), HyperLink)

                    Dim iGrupoAux As Integer
                    If Integer.TryParse(ddlGrupo.SelectedValue, iGrupoAux) Then
                        If iGrupoAux <= 0 Then
                            hl.Visible = False
                            lb.Visible = True
                            lb.Text = dr("Atividade").ToString
                            lb.CommandArgument = dr("Atividade").ToString
                        Else
                            hl.Visible = True
                            lb.Visible = False
                            hl.Text = dr("Atividade").ToString
                            hl.NavigateUrl = "paginax.aspx?atividade=" & dr("atividade").ToString & _
                                             "&visao=" & ddlVisao.SelectedIndex & _
                                             "&tomador=" & ddlTomador.SelectedValue & _
                                             "&status=" & ddlStatus.SelectedValue & _
                                             "&tributacao=" & ddlTributacao.SelectedValue & _
                                             "&simples=" & ddlSimples.SelectedValue & _
                                             "®ime=" & rblPeriodo.SelectedIndex & _
                                             "&inicio=" & ddlInicio.SelectedValue & _
                                             "&fim=" & ddlFim.SelectedValue
                        End If
                    End If
.....................................

grato.

http://www.vilmarbro.com.br
   
vilmarbr
Pontos: 2843
SAO PAULO
SP - BRASIL
ENUNCIADA !
Postada em 09/03/2012 11:24 hs         
Deu certo....[:D]



       Protected Sub btnExportarExcel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExportarExcel.Click
            Dim i, m, n As Integer

            Dim fName As String = "Resumo_Atividade_" & Date.Today.ToShortDateString & ".xls"

            Dim lb As LinkButton
            Dim hl As HyperLink
            Dim iGrupoAux As Integer

            Response.Clear()
            Response.AddHeader("content-disposition", "attachment;filename=" & fName)
            Response.ContentType = "application/vnd.ms-excel"

            Response.BufferOutput = True
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1")
            Response.Charset = "UTF-8"

            With MEUGRID
                For i = 0 To MEUGRID.Columns.Count - 1
                    If i = 0 Then
                        'Controla o Título do Gridview de acordo com a opção Marcada
                        If Integer.TryParse(ddlGrupo.SelectedValue, iGrupoAux) Then
                            If iGrupoAux <= 0 Then
                                Response.Write("Grupo;")
                            Else
                                Response.Write("Atividade;")
                            End If
                        End If
                    ElseIf i = 1 Then
                        Response.Write("Descricao;")
                    ElseIf i = 2 Then
                        Response.Write("Qtd. CCM;")
                    ElseIf i = 3 Then
                        Response.Write("Qtd. NFS-e;")
                    ElseIf i = 4 Then
                        Response.Write("Receita;")
                    ElseIf i = 5 Then
                        Response.Write("Deducoes;")
                    ElseIf i = 6 Then
                        Response.Write("Base Calculo;")
                    ElseIf i = 7 Then
                        Response.Write("ISS;")
                    ElseIf i = 8 Then
                        Response.Write("(%);")
                    ElseIf i = 9 Then
                        Response.Write("Crédito;")
                    ElseIf i = 10 Then
                        Response.Write("(%);")
                    Else
                        Response.Write(.Columns(i).HeaderText & ";")
                    End If
                Next

                Response.Write(Environment.NewLine)

                For m = 0 To .Rows.Count - 1
                    For n = 0 To .Rows.Count - 1
                        If n = 0 Then
                            If Integer.TryParse(ddlGrupo.SelectedValue, iGrupoAux) Then
                                If iGrupoAux <= 0 Then
                                    lb = CType(.Rows(m).Cells(n).FindControl("lb"), LinkButton)
                                    Response.Write(lb.Text & ";")
                                Else
                                    hl = CType(.Rows(m).Cells(n).FindControl("hl"), HyperLink)
                                    Response.Write(hl.Text & ";")
                                End If
                            End If
                        Else
                            Response.Write(.Rows(m).Cells(n).Text & ";")
                        End If
                    Next

                    Response.Write(Environment.NewLine)
                Next

                Response.End()
            End With

------

Podem guardar a receita de bolo agora, eheheheeh

Obrigado.

http://www.vilmarbro.com.br
   
Página(s): 1/1    


Seu Nome:

Seu eMail:

ALTERAR PARA MODO HTML
Mensagem:

[:)] = 
[:P] = 
[:(] = 
[;)] = 

HTML DESLIGADO

     
 VOLTAR

  



CyberWEB Network Ltda.    © Copyright 2000-2026   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página