Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET 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 October 10th, 2004, 05:01 AM
Authorized User
 
Join Date: Aug 2004
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to macupryk Send a message via Yahoo to macupryk
Default Im having a BIG issue here!

Im having a BIG issue here! Im trying to edit and implement a new instance of a Dropdownlist in a "DATALIST" not a DATAGRID.

I getting flack from everyone that I keep double posting things. It is not that I am doing purposely it is that
no one seems to get what I need help in understanding what to do. I dont want anyone upset with me , I am just busting my
head over this
Im not sure where to turn, I know that once I have the answer I will have seen it time and time again and didnt
realize that that was it all the time. It always seems to happen that way!

How do I setup a dropdownlist for (***Type***) in editmode.
Any starters. Any sites.I would appreciate any help.

Plus I need to implement a new intance in the DATALIST not GRID that is jumping way ahead of where I am.

Here is my code:
<CODE>



<ItemTemplate>
        <table width="400" style="font: 10pt verdana">
            <tr>
                <td>
                    <tr><td>***Type:****</td>
This dropdownlist works in browse <td><asp:DropDownList
AutoPostBack="True" id="ddlCOMMANDTYPE" DataSource='<%# BindTBCOMMANDTYPE() %>'
mode. selectedindex='<%#
GetSelectedIndexCOMMANDTYPE(DataBinder.Eval(Contai ner.DataItem, "CT_REF").ToString())%>' runat="server"
                    DataTextField="CT_DESCRIPTION"
DataValueField="CT_REF"></asp:DropDownList></td></tr>
                    <tr><td>Content:</td>
                    <td><%# Convert.ToString(DataBinder.Eval(Container.DataIte m,
"CM_CONTENT"))%></td></tr>
                </td>
            </tr>
        </table>
        <asp:LinkButton id="EditButton" Text="Edit" CommandName="Edit"
runat="server" />
    </ItemTemplate>
    <EditItemTemplate>
        <table width=400 style="font: 10pt verdana">
            <tr>
                <td>
                    <tr><td>***Type:****</td>
                    <tr><td>Content:</td>
                    <td><asp:TextBox id="CM_CONTENTTextBox" Text='<%#
DataBinder.Eval(Container.DataItem, "CM_CONTENT") %>' runat="server"/></td></tr>
                </td>
            </tr>
        </table>
        <asp:LinkButton id="UpdateButton" Text="Update" CommandName="Update"
runat="server" />
        <asp:LinkButton id="DeleteButton" Text="Delete" CommandName="Delete"
runat="server" />
        <asp:LinkButton id="CancelButton" Text="Cancel" CommandName="Cancel"
runat="server" />
    </EditItemTemplate>
</ASP:DataList>
<input type="hidden" id="PageSize" value="1" runat="server"
NAME="PageSize"> <input type="hidden" id="CurrentPage" value="1" runat="server"
NAME="CurrentPage">
<input type="hidden" id="TotalSize" runat="server" NAME="TotalSize">
<asp:LinkButton id="Prev" Text="<< Previous" OnClick="Page_DataList"
runat="server" />
&nbsp;
<asp:LinkButton id="Next" Text="Next >>" OnClick="Page_DataList"
runat="server" />
</form>
////////////////////////////////////////////////////////////////
public int GetSelectedIndexCOMMANDTYPE (string CT_REF)
{
int iLoop;
DataTable dt = ddlDataSet1.Tables["ddlCOMMANDTYPE"];
for (iLoop=0; iLoop < dt.Rows.Count; iLoop++)
{
    string srow = dt.Rows[iLoop]["CT_REF"].ToString();

    if(srow == CT_REF)
    {
        return iLoop;
    }
};
return 0;

}
//////////////////////////////////////////////////////////////////
public DataSet BindTBCOMMANDTYPE()
{
    OdbcConnection myConnection = new
OdbcConnection("DSN=POS;UID=system;PWD=system");

    // Populate the ddlDataSet1
    myConnection.Open();
    const string strSQLDDL = @"SELECT CT_REF, CT_DESCRIPTION FROM
TBCOMMANDTYPE ORDER BY CT_REF";
    OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL,
myConnection);
    ddlDataSet1.Clear();
    myDataAdapter.Fill(ddlDataSet1, "ddlCOMMANDTYPE");
    myDataAdapter.Dispose();
    myDataAdapter = null;
    myConnection.Close();
    return ddlDataSet1;
}
//************************************************** *********************

</CODE>

Any Advice you can give me would be so appreciated.

Thank you Sincerely.
Matt

Knowledge is to be shared.
__________________
Knowledge is to be shared.
 
Old October 10th, 2004, 05:24 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Take a look at these two articles:

http://www.dotnetjunkies.com/Tutoria...13EB11DC3.dcik
http://msdn.microsoft.com/library/de...verControl.asp

Both articles deal with a DataGrid, not a DataList, but you'll find that the concepts are pretty similar.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Im leanring a new language ironchef ASP.NET 1.0 and 1.1 Basics 1 December 3rd, 2007 09:39 AM
im new with c# i need help tunisiano C# 7 February 17th, 2007 04:54 AM
im new here and i need ur help.... momoi Beginning VB 6 2 January 30th, 2006 11:44 PM
Im new in P2PForum darkdog BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 2 June 20th, 2003 01:11 PM





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