black Posted March 12, 2009 at 12:23 PM Report Share #250217 Posted March 12, 2009 at 12:23 PM boas.... estou a desenvolver um projecto em asp.net c# estou a utilizar uma gridview em que faço a captação de um determinado valor e passo esse valor por get, porem não quero ver esse coluna, mas senão puser visible=false e deixa de captar o valor, sei que há uma forma de ocultar a coluna por código de forma a ficar invisível porem dar para conhecer na mesma o valor para passar, alguem sabe essa forma?... eu estou a passar assim: GridViewRow row = GridView1.SelectedRow; Response.Redirect("pagina10.aspx?id=" + row.Cells[0].Text + "&drop=" + row.Cells[3].Text + "&ano=" + row.Cells[2].Text); e quero por exemplo ocultar a coluna [3], mas poder continuar a captar o valor.... alguém me pode ajudar em c#??? .:: C ::. .::Haskell::. .::VB::. .::PHP::. Link to comment Share on other sites More sharing options...
Hellblazer Posted March 12, 2009 at 02:33 PM Report Share #250268 Posted March 12, 2009 at 02:33 PM Podes por simplesmente visible false e depois vais buscar os dados no codebehind ao datasource da gridview 🙂 There are two ways to write error-free programs; only the third one works. Link to comment Share on other sites More sharing options...
black Posted March 12, 2009 at 03:20 PM Author Report Share #250283 Posted March 12, 2009 at 03:20 PM e como faço isso?? eu ponho visible=false mas depois nao conseguer ir buscar valor nenhum.... como vou buscar ao codebehind ao datasource da gridview????? .:: C ::. .::Haskell::. .::VB::. .::PHP::. Link to comment Share on other sites More sharing options...
Hellblazer Posted March 12, 2009 at 03:23 PM Report Share #250286 Posted March 12, 2009 at 03:23 PM Se passares o DataSource para um DataTable apartir de la tens acesso aos valores mesmo nao estando visivel 🙂 There are two ways to write error-free programs; only the third one works. Link to comment Share on other sites More sharing options...
black Posted March 12, 2009 at 03:28 PM Author Report Share #250289 Posted March 12, 2009 at 03:28 PM e como passo??? eu utilizo o sqldatasource e nao tem nada com datatable!!!! desculpa mas sera que podes ser mais especifico??? .:: C ::. .::Haskell::. .::VB::. .::PHP::. Link to comment Share on other sites More sharing options...
Hellblazer Posted March 12, 2009 at 03:40 PM Report Share #250293 Posted March 12, 2009 at 03:40 PM Dim dView As DataView dView = CType(dataGridView1.DataSource, DataView) There are two ways to write error-free programs; only the third one works. Link to comment Share on other sites More sharing options...
Hellblazer Posted March 12, 2009 at 03:43 PM Report Share #250294 Posted March 12, 2009 at 03:43 PM Info sobre dataview http://msdn.microsoft.com/en-us/library/system.data.dataview.aspx There are two ways to write error-free programs; only the third one works. Link to comment Share on other sites More sharing options...
black Posted March 12, 2009 at 04:33 PM Author Report Share #250310 Posted March 12, 2009 at 04:33 PM e nao há forma mais simple? tive a pesquisar e encontrei o que precisava mas em vb e eu estou a trabalhar em c#.... o codigo em vb é o seguinte: No GridView: <asp:GridView id="GridView1" runat="server" OnRowDataBound="OcultarColuna"> No codebehind: 'rotina associada ao evento - OnRowDataBound para tornar invisível a coluna Id do GridView '0 é o indice da coluna que quero ocultar Public Sub OcultarColuna(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView1.RowDataBound Select Case e.Row.RowType Case DataControlRowType.Header e.Row.Cells(0).Visible = False Case DataControlRowType.DataRow e.Row.Cells(0).Visible = False Case DataControlRowType.Footer e.Row.Cells(0).Visible = False End Select End Sub sera que alguem me pode ajudar a fazer o mesmo em c#? .:: C ::. .::Haskell::. .::VB::. .::PHP::. Link to comment Share on other sites More sharing options...
Hellblazer Posted March 12, 2009 at 04:34 PM Report Share #250311 Posted March 12, 2009 at 04:34 PM http://converter.telerik.com/ There are two ways to write error-free programs; only the third one works. Link to comment Share on other sites More sharing options...
LCarreira Posted March 24, 2009 at 04:17 PM Report Share #253046 Posted March 24, 2009 at 04:17 PM Não sei se é isto que precisas, mas aqui vai... No código ASPX: <%--Coluna não visivel--%> <asp:BoundField DataField="Id" HtmlEncode="False" Visible="false" > </asp:BoundField> No evento Grid_SelectedIndexChanged string a = GridId.DataKeys[GridId.SelectedRow.RowIndex].Values[1].ToString(); Values[1] representa a ordem da DataKey na tua Grid (0,1,2,...) Caso queiras aceder a um valor de uma coluna visivel fazes: string a = GridId.SelectedRow.Cells[1].Text; onde Cells[1] representa a ordem da coluna na grid... Espero ter ajudado Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now