Unstoppable Domains

Need help with asp.net (Handler)

Spacemail by SpaceshipSpacemail by Spaceship
Watch

killay

Established Member
Impact
2
Hi,

Ok I hope you guys can help me on this one.
It might seem huge :(

I have two problems
As long as one of these problems is solved I'm truly greatful to you all :D

-1: I have a gridview with data from a database (name, picture, explenation, sex)
I would like to only have the admin (administrator role) to edit/delete it.
BUT when the admin clicks on edit, i want it to be redirected to another page (manage models.aspx) with the data on it (+ pagination to navigate through all "rows")

-2: on the modify page (managemodels.aspx) I have three templates (item, update, insert). How do I work with the checkboxes? also in the editTemplate how do I set the already inputted values in the textboxes? I mean you have the eval and bind, but it should be combined :S

handler:
Code:
<%@ WebHandler Language="VB" Class="Handler" %>

Imports System
Imports System.Web
Imports System.Data.SqlClient

Public Class Handler
    Implements IHttpHandler
    
    
    Public Sub ProcessRequest(ByVal context As HttpContext) Implements System.Web.IHttpHandler.ProcessRequest
        
        
        
        Dim con As New SqlConnection()
        con.ConnectionString = ConfigurationManager.ConnectionStrings("DataBaseConnectionString").ConnectionString
        
        ' Create SQL Command 
        
        Dim cmd As New SqlCommand()
        cmd.CommandText = "Select Naam,Geslacht,Foto,Beschrijving from Escorte" + _
                          " where ID =@ID"
        cmd.CommandType = System.Data.CommandType.Text
        cmd.Connection = con
        
        Dim ImageID As New SqlParameter("@ID", System.Data.SqlDbType.Int)
        ImageID.Value = context.Request.QueryString("ID")
        cmd.Parameters.Add(ImageID)
        con.Open()
        Dim dReader As SqlDataReader = cmd.ExecuteReader()
        dReader.Read()
        context.Response.BinaryWrite(DirectCast(dReader("Image"), Byte()))
        dReader.Close()
        con.Close()
    End Sub

    Public ReadOnly Property IsReusable() As Boolean Implements System.Web.IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property

End Class

managemodels.aspx:
Code:
<%@ Page Language="VB" MasterPageFile="~/MasterPage.Master" AutoEventWireup="false" CodeFile="ManageModels.aspx.vb" Inherits="ManageModels" title="Untitled Page" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
    <asp:FormView ID="FormView1" runat="server" AllowPaging="True" 
            BorderStyle="None" BorderWidth="1px" 
            CellPadding="3" CellSpacing="2" DataKeyNames="ID" DataSourceID="SqlDataSource1" 
            GridLines="Both" Height="180px" Width="418px">
            <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
            <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
            <EditItemTemplate>
                Vorig Naam:
                <asp:Label ID="IDLabel" runat="server" Text=' <%# Eval("Naam") %>' />
                Nieuwe Naam: <asp:TextBox ID="ImageNameTextBox" runat="server" 
                    Text='<%# Bind("Naam") %>' />
                <br />
                <asp:Image ID="Image1" runat="server" Height="144px" 
                    ImageUrl='<%# Eval("ID", "~/handler.ashx?ID={0}") %>' Width="210px" />
                <br />
                 <asp:FileUpload ID="FileUpload1" runat="server" Height="20px" Width="302px" />
                <br />
                <asp:RadioButton ID="RadioButton1" runat="server" Text='<%# Bind("Geslacht") %>' />
                <br />
                <asp:TextBox ID="RadioButton2" runat="server" Text='<%# Bind("Beschrijving") %>' />
                <br />
                <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                    CommandName="Update" Text="Update" />
                 <asp:LinkButton ID="UpdateCancelButton" runat="server" 
                    CausesValidation="False" CommandName="Cancel" Text="Cancel" />
            </EditItemTemplate>
            <InsertItemTemplate>
                Naam:
                <asp:TextBox ID="ImageNameTextBox" runat="server" 
                    Text='<%# Bind("Naam") %>' />
                <br />
                <asp:FileUpload ID="FileUpload1" runat="server" Height="20px" Width="302px" />
                <br />
                <asp:RadioButton ID="RadioButton1" runat="server" Text='<%# Bind("Geslacht") %>' />
                <br />
                <asp:TextBox ID="RadioButton2" runat="server" Text='<%# Bind("Beschrijving") %>' />
                <br />
                <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                    CommandName="Insert" Text="Insert" />
                 <asp:LinkButton ID="InsertCancelButton" runat="server" 
                    CausesValidation="False" CommandName="Cancel" Text="Cancel" />
            </InsertItemTemplate>
            <ItemTemplate>
                Naam:
                <asp:Label ID="IDLabel" runat="server" Text='<%# Eval("Naam") %>' />
                <br />
                <asp:Image ID="Image1" runat="server" Height="144px" Width="210px" ImageUrl='<%# Eval("ID", "~/handler.ashx?ID={0}") %>'/>
                <br />
                <asp:Label ID="Label1" runat="server" Text=<%# Eval("Geslacht") %>></asp:Label>
                <br />
                <asp:Label ID="Label2" runat="server" Text='<%# Eval("Beschrijving") %>'></asp:Label>
                <br />
                <asp:LinkButton ID="NieuwButton" runat="server" CommandName="New">Nieuw</asp:LinkButton>
                    
                <asp:LinkButton ID="WijzigButton" runat="server" CommandName="Edit" >Wijzig</asp:LinkButton>
                <br />
            </ItemTemplate>
            <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
        </asp:FormView>
</asp:Content>

gridview:
Code:
<asp:GridView ID="Models" runat="server" AllowPaging="True" PageSize="15" 
        AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
        AllowSorting="True" BackColor="White" BorderColor="#999999" BorderStyle="Solid" 
        BorderWidth="1px" CellPadding="3" ForeColor="Black" GridLines="Vertical">
        <Columns>
            <asp:ImageField>
            </asp:ImageField>
            <asp:BoundField DataField="GebruikersNaam"  
                SortExpression="GebruikersNaam" />
            <asp:BoundField />
            <asp:CommandField ShowEditButton="True" />
        </Columns>
        <FooterStyle BackColor="#CCCCCC" />
        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
        <EmptyDataTemplate>
            Er zijn momenteel geen Modellen te vinden... Probeer later opnieuw.
        </EmptyDataTemplate>
        <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="#CCCCCC" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        SelectCommand="SELECT [Naam], [Geslacht], [Beschrijving], [Image] FROM [Models]">
    </asp:SqlDataSource>

That would be my final question of today at least :D
Hope you guys can help me on this :)

Kind regards
and thanks in advance
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back