I can't see the image files I included in my asp.net page. The images are put into the linked access database table first, and I also included the images into the same folder as my web application.
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" AutoGenerateSelectButton="True" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnPageIndexChanging="GridView1_PageIndexChanging" CellPadding="5" Font-Names="Arial">
<Columns>
<asp:BoundField DataField="ProductID" HeaderText="Product ID" />
<asp:BoundField DataField="ProductName" HeaderText="Product Name" />
<asp:BoundField DataField="ProductPrice" HeaderText="Product Price" />
<asp:BoundField DataField="QtyInStock" HeaderText="Quantity in stock" />
<asp:ImageField DataImageUrlField="ProductImage" HeaderText="Image">
<ControlStyle BorderStyle="Groove" Height="260px" Width="300px" />
</asp:ImageField>
</Columns>
<EmptyDataRowStyle BackColor="White" />
<FooterStyle BackColor="White" />
<HeaderStyle BackColor="White" />
<PagerStyle BackColor="White" />
<RowStyle BackColor="White" />
</asp:GridView>
The product image field is where the images should be.
Related
Hello i want gridview which should be like
|Sl No|Std No|Student Name|Total Amount|Paid Amount|Unpaid Amount|Action|
Here I am setting Sl No ,Unpaid Amount , and Action Columns by Template Field.And Other i am directly getting from mysql DB and binding to gridview. But the columns from DB are apending to end of those 3 TemplateFields.And i cant use BoundFields for those 4 Fields from DB.
MY CODE IS LIKE THIS
<div class="GridviewDiv">
<asp:GridView runat="server" ID="gvDetails" AllowPaging="false" AutoGenerateColumns="true" Width="100%" OnRowDataBound="GridView1_RowDataBound1">
<HeaderStyle CssClass="headerstyle" />
<Columns>
<asp:TemplateField HeaderText="SlNo">
<ItemTemplate>
<%#Container.DataItemIndex+1 %>
<asp:Label ID="serialID" runat="server" Visible="false"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<%-- HERE I WANT THOSE COLUMNS FROM DATABASE--%>
<asp:TemplateField HeaderText="Unpaid Amount">
<ItemTemplate>
<asp:Label ID="UnpaidText" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Take Fee">
<ItemTemplate>
<asp:Button ID="TakeFeeCash" runat="server" BackColor="#2C6AA0" BorderColor="#2C6AA0" align="right"
BorderStyle="Ridge" Font-Bold="True" ForeColor="White" OnClick="FeeCashButton_click"
Text="Take Fee" CommandName="Select" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
What i am getting is like this
IMAGE:
How to set my columns like above format?
Please Help.
I am using ASP.net and at some point I have a gridview that doesn't show up in my browser when I debug my project. On that same page do I use a textbox and that one does show up.
This is the HTML.
<%# Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/MasterPages/SvShop.Master" CodeBehind="Mijnoverzicht.aspx.vb" Inherits="SvShop.Mijnoverzicht" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h1>Mijn Artikelen</h1>
<table>
<tr>
<td>Email</td>
<td>
<asp:TextBox ID="txtMijnEmail" runat="server" CssClass="tekstvak" Width="190px"></asp:TextBox>
</td>
</tr>
</table>
<div class="OverzichtMijn">
<asp:GridView ID="GridViewMijn" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataSourceID="MijnDataSource" AllowSorting="True" Width="845px">
<Columns>
<asp:BoundField DataField="ArtikelBeschrijving" HeaderText="Beschrijving" SortExpression="ArtikelBeschrijving" />
<asp:BoundField DataField="ArtikelPrijs" HeaderText="Prijs" SortExpression="ArtikelPrijs" />
<asp:BoundField DataField="ArtikelAankoopdatum" HeaderText="Aankoopdatum" SortExpression="ArtikelAankoopdatum" />
<asp:BoundField DataField="ArtikelTekoopgezet" HeaderText="Tekoopgezet" SortExpression="ArtikelTekoopgezet" />
<asp:BoundField DataField="GebruikersNaam" HeaderText="Naam" SortExpression="GebruikersNaam" />
<asp:BoundField DataField="GebruikersVoornaam" HeaderText="Voornaam" SortExpression="GebruikersVoornaam" />
<asp:BoundField DataField="GebruikersEmail" HeaderText="Email" SortExpression="GebruikersEmail" />
<asp:BoundField DataField="GebruikersGSM" HeaderText="GSM" SortExpression="GebruikersGSM" />
</Columns>
<EditRowStyle CssClass="GridViewEditRow" />
</asp:GridView>
<asp:SqlDataSource ID="MijnDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SvShopInternString %>" ProviderName="<%$ ConnectionStrings:SvShopInternString.ProviderName %>" SelectCommand="SELECT tblArtikel.ArtikelBeschrijving, tblArtikel.ArtikelPrijs, tblArtikel.ArtikelAankoopdatum, tblArtikel.ArtikelTekoopgezet, tblGebruiker.GebruikersNaam, tblGebruiker.GebruikersVoornaam, tblGebruiker.GebruikersEmail, tblGebruiker.GebruikersGSM FROM ((tblArtikel INNER JOIN tblGebruiker ON tblArtikel.GebruikersID = tblGebruiker.GebruikersID) INNER JOIN tblRubriek ON tblArtikel.RubriekID = tblRubriek.RubriekID) WHERE (tblGebruiker.GebruikersEmail = '#Email')"></asp:SqlDataSource>
</div>
</asp:Content>
This is the browser view.
The problem should be in this line of code.
<asp:SqlDataSource ID="MijnDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SvShopInternString %>" ProviderName="<%$ ConnectionStrings:SvShopInternString.ProviderName %>" SelectCommand="SELECT tblArtikel.ArtikelBeschrijving, tblArtikel.ArtikelPrijs, tblArtikel.ArtikelAankoopdatum, tblArtikel.ArtikelTekoopgezet, tblGebruiker.GebruikersNaam, tblGebruiker.GebruikersVoornaam, tblGebruiker.GebruikersEmail, tblGebruiker.GebruikersGSM FROM ((tblArtikel INNER JOIN tblGebruiker ON tblArtikel.GebruikersID = tblGebruiker.GebruikersID) INNER JOIN tblRubriek ON tblArtikel.RubriekID = tblRubriek.RubriekID) WHERE (tblGebruiker.GebruikersEmail = '#Email')"></asp:SqlDataSource>
The parameter
#Email
gets his value from the textbox above with this code:
Protected Sub txtMijnEmail_TextChanged(sender As Object, e As EventArgs) Handles txtMijnEmail.TextChanged
MijnDataSource.SelectCommand.Replace("#Email", txtMijnEmail.Text)
GridViewMijn.DataBind()
End Sub
Overkill - just add a Control Parameter to the SelectParameters:
<asp:SqlDataSource ID="MijnDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:SvShopInternString %>"
ProviderName="<%$ ConnectionStrings:SvShopInternString.ProviderName %>"
SelectCommand="SELECT <snip> WHERE (tblGebruiker.GebruikersEmail = '#Email')">
<SelectParameters>
<asp:ControlParameter
ControlID="txtMijnEmail"
PropertyName="Text"
Name="Email">
</asp:ControlParameter>
</SelectParameters>
</asp:SqlDataSource>
And obviously make sure your Select command returns a dataset when a valid email is provided.
Also consider temporarily setting GridViewMijn.ShowHeader="true" and GridViewMijn.EmptyDataText="No Data returned" for debugging purposes
I am trying to add a DropDownList into the DataGrid so the location column can be easily changed. I am getting an error with TemplateField, itemtemplate, label and DropDownList. I get the build error:
is not allowed within a
'System.Web.UI.WebControls.DataGridColumnCollection'.
<asp:DataGrid runat="server" CssClass="tblResults" OnItemDataBound="dgList_ItemCreated" AllowSorting="true" OnSortCommand="dgTrailer_Sort" ID="dgTrailers" DataKeyField="ID" AutoGenerateColumns="false">
<Columns>
<asp:BoundColumn DataField="TrailerOwner" HeaderText="Owner" SortExpression="TrailerOwner"></asp:BoundColumn>
<asp:BoundColumn DataField="TrailerMake" HeaderText="Trailer Make" SortExpression="TrailerMake"></asp:BoundColumn>
<asp:TemplateField HeaderText="Trailer Location">
<itemtemplate>
<asp:Label ID="lblLocation" runat="server" Text='<%# Eval("Location") %>' Visible = "false" />
<asp:DropDownList ID="ddlLocation" runat="server">
</asp:DropDownList>
</itemtemplate>
</asp:TemplateField>
<asp:BoundColumn DataField="Year" HeaderText="Year" SortExpression="Year"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
TemplateField, itemtemplate, label and DropDownList all have green lines under them and which means its not a known element.
You should use TemplateColumn, when it comes to DataGrid as it is inherited from System.Web.UI.WebControls.DataGridColumn.
TemplateField is inherited from System.Web.UI.WebControls.DataControlField, which make sense with GridView.
i want to remove this column from gridview i try to add values in dropdownlist in grdiview but when i add it works fine but this column in black color appears...
how i remove it..
grdiview html
<asp:BoundField DataField="DocType" HeaderText="Document" />
<asp:BoundField DataField="DepType" HeaderText="Department" />
<asp:BoundField HeaderText="ApproveID" DataField="ApproveID"
></asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lblCountry" runat="server" Text='<%#
Eval("ApproveID") %>' Visible = "false" />
<asp:DropDownList ID="DropDownList4" runat="server"
class="vpb_dropdown">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
First make sure AutoGenerateColumns="false" is set on your GridView, and then delete the lines
<asp:BoundField HeaderText="ApproveID" DataField="ApproveID"></asp:BoundField>
from your HTML. When you turn off AutoGenerateColumns, you will need to add each column manually.
I want to select multible record in one time and update them by a buttom
I searched the internet by it's always cs and I want vb.net
I did my grid view as following
<asp:GridView ID="GridView1" runat="server" AutoGenerateCheckboxColumn="True"
CheckboxColumnIndex="0" AllowSorting="true"
AutoGenerateColumns="False" DataKeyNames="USER_ID"
DataSourceID="SqlDataSource1StudentActivList" CellPadding="2">
<Columns>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="FirstName" HeaderText="FirstName"
SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName"
SortExpression="LastName" />
<asp:BoundField DataField="MiddleName" HeaderText="MiddleName"
SortExpression="MiddleName" />
<asp:BoundField DataField="ProgramCODE" HeaderText="ProgramCODE"
SortExpression="ProgramCODE" />
<asp:BoundField DataField="USER_NAME" HeaderText="USER_NAME"
SortExpression="USER_NAME" />
<asp:BoundField DataField="USER_Email" HeaderText="USER_Email"
SortExpression="USER_Email" />
<asp:BoundField DataField="MajorNameInEnglish" HeaderText="MajorNameInEnglish"
SortExpression="MajorNameInEnglish" />
<asp:BoundField DataField="GivenStudentID" HeaderText="GivenStudentID"
SortExpression="GivenStudentID" />
<asp:BoundField DataField="accepted" HeaderText="accepted"
SortExpression="accepted" />
<asp:BoundField DataField="Gender" HeaderText="Gender"
SortExpression="Gender" />
<asp:BoundField DataField="USER_ID" HeaderText="USER_ID" ReadOnly="True"
SortExpression="USER_ID" />
</Columns>
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1StudentActivList" runat="server"
ConnectionString="<%$ ConnectionStrings:mydbConnectionString %>"
SelectCommand="SELECT DISTINCT [FirstName], [LastName], [MiddleName], [ProgramCODE], [USER_NAME], [USER_Email], [MajorNameInEnglish], [GivenStudentID], [accepted], [Gender], [USER_ID] FROM [DIP_StudentsActivationList]">
</asp:SqlDataSource>
<p><asp:Label ID="lblSelection" runat="server" /></p>
<asp:Button ID="btupdate" runat="server" Text="Update" />
this is the VB code(converted) it's not what i want but i think i can deal with it
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Public Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As EventArgs)
If MultiSelectGridView1.SelectedDataKeys.Count > 0 Then
lblSelection.Text = "You selected employees: "
For Each k As DataKey In MultiSelectGridView1.SelectedDataKeys
lblSelection.Text += k.Value.ToString() & ", "
Next
lblSelection.Text = lblSelection.Text.TrimEnd(","C, " "C)
Else
lblSelection.Text = "No employees selected"
End If
End Sub
End Class
and I want to change the accepted status in my database by clicking the buttom
any help please