Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 16th, 2007, 02:47 AM
Authorized User
 
Join Date: Apr 2006
Location: Virginia Beach, VA, USA.
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataList HELP with Updating

I cannot figure out how to get this simple DataList to update, I have the C# Beginning 2005 Databases - Watson, but I am just not getting it. Trie dusing Bind instead of Eval - no good. What do I need to do to edit the (int) L_Rank, (string) L_City and L_State? I am just not getting it. I have eight WROX books and an really confused. Any help GREATLY appreciated. Thank you.


<asp:DataList ID="DataList1" runat="server" DataSourceID="LinkInfoDataSource" OnEditCommand="myEditListHandler" OnCancelCommand="DataList1_CancelCommand" OnUpdateCommand="DataList1_UpdateCommand" >
<ItemTemplate>
            <asp:Label ID="L_IDLabel" runat="server" Text='<%# Eval("L_ID") %>'></asp:Label><br />
            <asp:Label ID="L_NameLabel" runat="server" Text='<%# Eval("L_Name") %>'></asp:Label><br />
            <asp:Label ID="L_RankLabel" runat="server" Text='<%# Eval("L_Rank") %>'></asp:Label><br />
            <asp:Label ID="L_CityLabel" runat="server" Text='<%# Eval("L_City") %>'></asp:Label><br />
            <asp:Label ID="L_StateLabel" runat="server" Text='<%# Eval("L_State") %>'></asp:Label><br />
            <asp:Button ID="Button1" runat="server" Text="Button" CommandName="edit" />
            <br />
        </ItemTemplate>
        <HeaderTemplate>
           <h3><b>
               <asp:Label ID="Label1" runat="server" BackColor="#FFC080" Font-Size="Larger" Text=" Basic Header Trial "></asp:Label></b>&nbsp;</h3>
        </HeaderTemplate>
        <SeparatorTemplate></SeparatorTemplate>
        <EditItemTemplate>
            EDIT Template<br />
            <asp:TextBox ID="L_IDTextBox" runat="server" Text='<%# Eval("L_ID") %>'></asp:TextBox><br />
            <asp:TextBox ID="L_NameTextBox" runat="server" Text='<%# Eval("L_Name") %>'></asp:TextBox><br />
            <asp:TextBox ID="L_RankTextBox" runat="server" Text='<%# Eval("L_Rank") %>'></asp:TextBox><br />
            <asp:TextBox ID="L_CityTextBox" runat="server" Text='<%# Eval("L_City") %>'></asp:TextBox><br />
            <asp:TextBox ID="L_StateTextBox" runat="server" Text='<%# Eval("L_State") %>'></asp:TextBox><br />
            <asp:Button ID="Button2" runat="server" Text="Update" CommandName="update" />
            <asp:Button ID="Button3" runat="server" Text="Cancel" CommandName="cancel" />
        </EditItemTemplate>
    </asp:DataList><asp:SqlDataSource ID="LinkInfoDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>"
        SelectCommand="SELECT [L_ID], [L_Name], [L_Rank], [L_City], [L_State] FROM [tblContractorLinkInfo] WHERE ([L_State] = @L_State)" >
        <SelectParameters>
            <asp:Parameter DefaultValue="va" Name="L_State" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>


CODE BEHIND *****

public partial class Basics : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    { }

    protected void myEditListHandler(Object src, DataListCommandEventArgs e)
    {
        DataList1.EditItemIndex = e.Item.ItemIndex;
        DataList1.DataBind();
    }
    protected void DataList1_CancelCommand(object source, DataListCommandEventArgs e)
    {
        DataList1.EditItemIndex = -1;
        DataList1.DataBind();
    }
    protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e)
    { }
}

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Datalist inside datalist amit.jagtap ASP.NET 2.0 Professional 1 September 4th, 2007 05:03 AM
Datalist not Updating.. slim182 ASP.NET 2.0 Basics 0 February 16th, 2007 11:48 AM
datalist sarah lee ASP.NET 1.0 and 1.1 Basics 0 October 18th, 2006 02:49 PM
Updating boolean values using datalist Scripts82 ASP.NET 1.0 and 1.1 Basics 1 September 20th, 2006 04:17 AM
DataList in DataList acko ASP.NET 1.0 and 1.1 Professional 3 July 9th, 2004 05:18 PM



All times are GMT -4. The time now is 12:38 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.