v1tal1ty Posted April 22, 2013 at 10:10 AM Report #504281 Posted April 22, 2013 at 10:10 AM Boas, venho mais uma vez apresentar a minha duvida a este grande fórum. Trata se de um site de partilha de ficheiros. aqui tenho a tabela: DataTable table = new DataTable(); table.Columns.Add(new DataColumn("Título do documento", typeof(string))); table.Columns.Add(new DataColumn("Nome", typeof(string))); table.Columns.Add(new DataColumn("Data de criação", typeof(string))); table.Columns.Add(new DataColumn("Tamanho", typeof(string))); table.Columns.Add(new DataColumn("Tipo de documento", typeof(string))); table.Columns.Add(new DataColumn("Formato", typeof(string))); // este campo so é preenchido mais tarde. Tenho uma gridview assim: <asp:GridView ID="GridView1" runat="server" AllowPaging="True" onrowdatabound="GridView1_RowDataBound" onpageindexchanging="GridView1_PageIndexChanging" PageSize="9" CssClass="GridStyle" > <HeaderStyle BackColor="#CCCCCC" /> <PagerStyle Font-Bold="True" Font-Size="Medium" Height="25px" /> </asp:GridView> No row databound verifico cada campo addicionado, tirando de coluna "Nome", e ver a extensao para addicionar a imagem. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string[] str = e.Row.Cells[1].Text.Split('.'); switch (str[1]) { case "jpg": e.Row.Cells[5].Text = "<asp:ImageButton runat='server' ImageUrl='~/IMGicon/icon_imagem.jpg' onclick='ImageButton1_Click' />"; break; case "docx": e.Row.Cells[5].Text = "<asp:ImageButton runat='server' ImageUrl='~/IMGicon/icon_word.jpg' onclick='ImageButton1_Click' />"; break; default: e.Row.Cells[5].Text = "<asp:ImageButton runat='server' ImageUrl='~/IMGicon/icon_docgeral.jpg' onclick='ImageButton1_Click' />"; break; } } } Acham que é método apropriado ou não? e ja agora se for, tentam me dizer o porque nao me aparecem as imagens. Porque eu ja os tive visiveis mas dps de addicionar onclick, desapereceram... deste já agradeço Cumps
v1tal1ty Posted April 23, 2013 at 03:13 PM Author Report #504547 Posted April 23, 2013 at 03:13 PM Resolvido...
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