Wrox Programmer Forums
|
BOOK: Beginning ASP.NET Dynamic Websites w/ Web Matrix
This is the forum to discuss the Wrox book Beginning Dynamic Websites: with ASP.NET Web Matrix by Dave Sussman, James Greenwood, Alex Homer, Colt Kwong, John M. West; ISBN: 9780764543746
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET Dynamic Websites w/ Web Matrix section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 17th, 2005, 10:20 AM
Authorized User
 
Join Date: Jan 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Displaying data - a simple question for the expert

I am already using a data grid to dispay data from the database. Which is fine, except that I wand to add Edit and Delete links in the grid table. I was thinking of going down the DataPanel route. Can you help me translate the following code such that i can still use my html <tr><td> tags to place the data I want and enter my Edit and Delete links as asp:hyperlink.

<%@ Page Language="C#" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

    void Page_Load(Object sender, EventArgs e)
    {
        DataGrid1.DataSource=ListJobs();
        DataGrid1.DataBind();
     }


        System.Data.DataSet ListJobs() {
            string connectionString = "server=\'(local)\'; trusted_connection=true; database=\'nkonye_test\'";
            //string connectionString = ConfigurationSettings.AppSettings("ConnectionStrin g");
            System.Data.IDbConnection dbConnection = new System.Data.SqlClient.SqlConnection(connectionStri ng);


            string queryString = "SELECT [Jobs].* FROM [Jobs]";
            System.Data.IDbCommand dbCommand = new System.Data.SqlClient.SqlCommand();
            dbCommand.CommandText = queryString;
            dbCommand.Connection = dbConnection;

            System.Data.IDbDataAdapter dataAdapter = new System.Data.SqlClient.SqlDataAdapter();
            dataAdapter.SelectCommand = dbCommand;
            System.Data.DataSet dataSet = new System.Data.DataSet();
            dataAdapter.Fill(dataSet);

            return dataSet;
        }

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <table cellpadding="0" width="750" align="center" cellpsacing="0">
            <tbody>
                <tr>
                    <td align="middle" colspan="2">
                        List | <a href="search.aspx">Search</a> | <a href="index.aspx">Log out</a>
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;</td>
                </tr>
                <tr>
                    <td align="middle" colspan="2">
                        <h2>List jobs
                        </h2>
                    </td>
                </tr>
                <tr>
                    <td align="middle" colspan="2">
                        <a href="add_job.aspx">Add new job</a></td>
                </tr>
                <tr>
                    <td>
                        &nbsp;</td>
                </tr>
            </tbody>
        </table>
        <asp:DataGrid id="DataGrid1" runat="server" Autogeneratecolumns="False" align="center" width="650px" ForeColor="Black" CellPadding="4" BackColor="White" BorderColor="#DEDFDE" BorderWidth="1px" GridLines="Vertical" BorderStyle="None">
            <FooterStyle backcolor="#CCCC99"></FooterStyle>
            <HeaderStyle font-bold="True" forecolor="White" backcolor="#6B696B"></HeaderStyle>
            <PagerStyle horizontalalign="Right" forecolor="Black" backcolor="#F7F7DE" mode="NumericPages"></PagerStyle>
            <SelectedItemStyle font-bold="True" forecolor="White" backcolor="#CE5D5A"></SelectedItemStyle>
            <AlternatingItemStyle backcolor="White"></AlternatingItemStyle>
            <ItemStyle backcolor="#F7F7DE"></ItemStyle>
            <Columns>
                <asp:BoundColumn DataField="job_id" HeaderText="ID" ReadOnly="True" />
                <asp:BoundColumn DataField="job_title" HeaderText="Title"></asp:BoundColumn>
                <asp:BoundColumn DataField="location" HeaderText="Location"></asp:BoundColumn>
                <asp:BoundColumn DataField="job_type" HeaderText="Job Type"></asp:BoundColumn>
                <asp:BoundColumn DataField="salary" HeaderText="Salary" DataFormatString="{0:c}"></asp:BoundColumn>
                <asp:BoundColumn DataField="job_type" HeaderText="Type"></asp:BoundColumn>
                <asp:EditCommandColumn EditText="Edit" CancelText="Cancel" UpdateText="Update" />
            </Columns>
        </asp:DataGrid>
    </form>
</body>
</html>





Similar Threads
Thread Thread Starter Forum Replies Last Post
simple question petergoodman XSLT 8 July 18th, 2008 07:57 AM
I have a question about Chapter04 in Expert... aeroboy32000 VB Databases Basics 1 November 1st, 2007 03:23 PM
Very Simple Question YoungLuke C# 2 May 4th, 2007 02:23 AM
simple query for displaying groups... suraj SQL Language 1 September 2nd, 2005 06:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.