I would try something like...
 ASPX File:
 <asp:Label id="lblPhone" runat="server" Text="Phone" />
<asp:TextBox id=txtPhone runat="server" />
 CS File:
  
public void Edit_Click(object sender, EventArgs e)
{

...database connection stuff here....

SqlDataReader dataReader;

conn.Open();
dataReader = cmd.ExecuteReader();

if(dataReader.HasRows)
{
while(dataReader.Read())
{
if(!(System.Convert.IsDBNull(dataReader["Phone"])))
{
txtPhone.Text = (string) dataReader["Phone"];
}

}

dataReader.Close();
conn.Close();
}


 On 7/3/05, Michael Swanson <[EMAIL PROTECTED]> wrote: 
> 
> Hi,
> I need some help going through each record in a dataset. I am 
> familiar with how to do it with asp, but asp.net <http://asp.net/> has got 
> me 
> confused. I have figured out how to bind the records I want to 
> bind, but now I want to be able to go forward or backwards through 
> the data. I have enclosed the current code I am using. If anyone 
> could help I would appreciate it, and C# is the language I am 
> using. Thanks, now here is the code:
> 
> <%@ Page language="c#" Codebehind="Customers.aspx.cs" 
> AutoEventWireup="false" Inherits="KcMedJobs.Customers" %>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
> <HTML>
> <HEAD>
> <title>Customers</title>
> <meta name="GENERATOR" Content="Microsoft Visual 
> Studio .NET 7.1">
> <meta name="CODE_LANGUAGE" Content="C#">
> <meta name="vs_defaultClientScript" 
> content="JavaScript">
> <meta name="vs_targetSchema" 
> content="http://schemas.microsoft.com/intellisense/ie5";>
> </HEAD>
> <body>
> <form id="Form1" method="post" runat="server">
> <P>
> <asp:Label id="lblCustomerId" 
> runat="server">Customer Id</asp:Label>
> <asp:TextBox id="txtCustomerId" 
> runat="server" Text='<%# DataBinder.Eval(test1, "Tables
> [tblCustomers].DefaultView.[0].CustomerId") %>' ReadOnly="True">
> </asp:TextBox></P>
> <P>
> <asp:Label id="lblFirstName" 
> runat="server">First Name</asp:Label>
> <asp:TextBox id="txtFirstName" 
> runat="server" Text='<%# DataBinder.Eval(test1, "Tables
> [tblCustomers].DefaultView.[0].FirstName") %>' Width="168px">
> </asp:TextBox>
> <asp:Label id="lblLastName" 
> runat="server">Last Name</asp:Label>
> <asp:TextBox id=txtLastName 
> runat="server" Width="168px" Text='<%# DataBinder.Eval(test1, "Tables
> [tblCustomers].DefaultView.[0].LastName") %>'>
> </asp:TextBox></P>
> <P>
> <asp:Label id="lblCompanyName" 
> runat="server">Company Name</asp:Label>
> <asp:TextBox id=txtCompanyName 
> runat="server" Width="272px" Text='<%# DataBinder.Eval(test1, "Tables
> [tblCustomers].DefaultView.[0].CompanyName") %>'>
> </asp:TextBox></P>
> <P>
> <asp:Label id="lblEmailAddress" 
> runat="server">Email Address</asp:Label>
> <asp:TextBox id="txtEmailAddress" 
> runat="server" Text='<%# DataBinder.Eval(test1, "Tables
> [tblCustomers].DefaultView.[0].EmailAddress") %>' Width="280px">
> </asp:TextBox></P>
> <P>
> <asp:Label id="lblStreetAddress" 
> runat="server">Street Address</asp:Label>
> <asp:TextBox id="txtStreetAddress" 
> runat="server" Text='<%# DataBinder.Eval(test1, "Tables
> [tblCustomers].DefaultView.[0].StreetAddress") %>' Width="280px">
> </asp:TextBox></P>
> <P>
> <asp:Label id="lblCity" 
> runat="server">City</asp:Label>
> <asp:TextBox id="txtCity" 
> runat="server" Text='<%# DataBinder.Eval(test1, "Tables
> [tblCustomers].DefaultView.[0].City") %>'>
> </asp:TextBox>
> <asp:Label id="lblState" 
> runat="server">State</asp:Label>
> <asp:TextBox id="txtState" 
> runat="server" Text='<%# DataBinder.Eval(test1, "Tables
> [tblCustomers].DefaultView.[0].State") %>'>
> </asp:TextBox>
> <asp:Label id="lblZip" 
> runat="server">Zip Code</asp:Label>
> <asp:TextBox id=txtZip 
> runat="server" Text='<%# DataBinder.Eval(test1, "Tables
> [tblCustomers].DefaultView.[0].Zip") %>'>
> </asp:TextBox></P>
> <P>
> <asp:Label id="lblPhone" 
> runat="server">Phone</asp:Label>
> <asp:TextBox id=txtPhone 
> runat="server" Text='<%# DataBinder.Eval(test1, "Tables
> [tblCustomers].DefaultView.[0].Phone") %>'>
> </asp:TextBox>
> <asp:Label id="lblPassword" 
> runat="server">Password</asp:Label>
> <asp:TextBox id=txtPassword 
> runat="server" Text='<%# DataBinder.Eval(test1, "Tables
> [tblCustomers].DefaultView.[0].CustomerPassword") %>'>
> </asp:TextBox></P>
> <P>
> <asp:Button id="btnPrevious" 
> runat="server" Text="Previous Record"></asp:Button>
> <asp:Button id="btnNext" 
> runat="server" Text="Next Record"></asp:Button></P>
> </form>
> </body>
> </HTML>
> 
> 
> 
> 
>  ------------------------------
> YAHOO! GROUPS LINKS 
> 
> 
>    - Visit your group 
> "AspNetAnyQuestionIsOk<http://groups.yahoo.com/group/AspNetAnyQuestionIsOk>" 
>    on the web.
>     - To unsubscribe from this group, send an email to:
>    [EMAIL PROTECTED]<[EMAIL PROTECTED]>
>     - Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
>    Service <http://docs.yahoo.com/info/terms/>. 
> 
> 
>  ------------------------------
> 



-- 
Thank you,
Ryan Olshan
<asp:WebProgrammer />
TeraNet Systems
http://www.teranetsystems.com


[Non-text portions of this message have been removed]



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to