|
I need to use it to show data for products or shops
As I’m making a e-commerce site
So, I want to know how I use the repeater in a dynamic way
To support the rows that was selected
And to target every column in a label and to put the title beside it
Thanks for help!
Ah_Mohsen
|
|
|
|
|
Wrong forum, it should be in the ASP.NET forum.
But:
in the aspx file:
<br />
...<br />
<asp:Repeater ID="MyRepeater" runat="server"><br />
<ItemTemplate><br />
<br />
<%# ((MyProductClass)DataItem.Container).ProductName %><br />
<br />
</ItemTemplate><br />
</asp:Repeater><br />
<br />
...<br />
in the .cs file
Page_Load()
{
...
List<MyProductClass> products = MyProductClass.GetProductListFromDatabaseOrSomething();
MyRepeater.DataSource = products;
MyRepeater.DataBind();
...
}
it's usual practice to put the above code within a if (!IsPostBack) {... } block so that it only gets loaded on the first page load rather than after every postback.
Hope that helps,
ChrisB
|
|
|
|
|
Sorry, the first block should read:
<br />
...<br />
<asp:Repeater ID="MyRepeater" runat="server"><br />
<ItemTemplate><br />
<br />
<%# ((MyProductClass)DataItem.Container).ProductName %><br />
<br />
</ItemTemplate><br />
</asp:Repeater><br />
<br />
...<br />
|
|
|
|
|
I put this in m code:
public class Row : System.Windows.Forms.ListViewItem<br />
{<br />
public int id;<br />
public int online;<br />
}
And have this code
ListViewItem item = new ListViewItem(new string[] {reader[NAME].ToString(), reader[GAME].ToString(), reader[BNAME].ToString(), reader[BOARD].ToString()});<br />
Row row = (Row)item; <-- ERROR OCCURS HERE<br />
row.id = Convert.ToInt32(reader[ID].ToString());<br />
row.on1ine = Convert.ToInt32(reader[ONLINE].ToString());<br />
MainForm.listView1.Items.Add(row);
But i get the above error, that it couldn't cast ListViewItem as Row. Ive done this before with TreeNode and it all worked fine, what wrong with this one?
Why did my row.online get replaced with row.removed, it doesn't do it outside the code brackets?
-- modified at 20:31 Tuesday 10th October, 2006
|
|
|
|
|
I'm now just storing row in item.Tag, and it works (of course) but i still want to know why this won't work, i just can't see it.
|
|
|
|
|
Because ListViewItem and Row are different classes and don't have
1. an is-a relationship
2. implicit conversion operators.
It obviously won't work with TreeNode also,as that class is not related in any way to the Row class that you wrote. You probably would have used the Tag property, just like you did now.
|
|
|
|
|
Actually i didn't use the tag.
Whith the tree node i had:
public class Cheat : Windows.Forms.TreeNode
{
public string code;
public string gameid;
lots of other public strings
}
My class inherited from the TreeNode.
So i had
Cheat oNode = new Cheat();
oNode.code = stuff
oNode.gameid = stuff
this.treeview1.nodes.Add(oNode);
and i could go:
foreach(Cheat oNode in treeview1.selectednodes)
and
TreeNode main = new TreeNode();
Cheat gNode = (Cheat) main;
or
Cheat gNode = new Cheat();
TreeNode main = (TreeNode)gNode;
Oh, and yes, when getting the nodes back from the list they still had all the values that where stored in my custom things by just going
Cheat check = (Cheat)this.treeView1.SelectedNode;
MessageBox.Show("The code in the node is... " + check.code);
-- modified at 23:37 Tuesday 10th October, 2006
|
|
|
|
|
That code works because your Cheat class inherited from the TreeNode, which is exactly what you were casting it to and from. A TreeNode has no relation to a Row
- Aaron
|
|
|
|
|
This works as you create a Cheat object, store its reference using a variable of its base class (TreeNode ) and cast back later. Hereby the real object on the heap stays the same (Cheat object) all time long.
The Row example doesn't work as you create an object of the base class (ListViewItem ) and afterwards try casting to a sub class. This simply can't be done as the object on the heap is now Row .
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
If possible could anyone please suggest how to do Forcolor change in disabled mode (Black color) for Drop downn or combo box.
I got color change fine but i am having problem in binding all the items.I cannot see items after color change ,i just see something like System.Data.Datarow in the place of items in combobox.
I am using Window forms with C# (ASP.NET 1.1 framework) ,visual studio 2003.
Thanks
OR
Suggest some other way to do the forecolor change in disable mode for combobox.
|
|
|
|
|
What do you mean by disabled mode? I don't quite get it.
|
|
|
|
|
Hi ,
Disabled mode means when we set Enable property to false.Than it does not allow use to handle the control.Disable means you cannot edit,or nothing you can do.
Is this clarify your doubt?
|
|
|
|
|
Yeah i thought that what you meant, but i can't seem to be able to change any colours when its disabled.
|
|
|
|
|
Hi again,
Yes you can change the forecolor.Just go through this example :
http://www.codeproject.com/cs/miscctrl/disabledcombodisplay.asp
But for me the forecolor is changing but it is giving problem in displaying all the items of the combobox.It just displays one and it gets repeated several times.Just check the code of the above example.
May be you can suggest some more ideas.
Thanks
|
|
|
|
|
error CS1577: Assembly generation failed -- Referenced assembly 'NCI.EasyObjects' does not have a strong name
error CS1577: Assembly generation failed -- Referenced assembly 'Microsoft.Practices.EnterpriseLibrary.Data' does not have a strong name
I am referancing these DLLs inside my COM dll.
|
|
|
|
|
kolu narayan wrote: CS1577
See if this KB article[^] helps.
led mike
|
|
|
|
|
Thanks for your reply.
This is what happening, i had tried your suggestion as well. but unfortunately things didnt well.
I have a COM dll in C# which i had named 'MyWrapper.dll'. Now in this dll i am referencing other 3rd party dll's which are
'NCI.EasyObjects.dll' and
'Microsoft.Practices.EnterpriseLibrary.Data.dll'. Now when i tried to strong name my MyWrapper.dll it gives the following error.
error CS1577: Assembly generation failed -- Referenced assembly 'NCI.EasyObjects' does not have a strong name
error CS1577: Assembly generation failed -- Referenced assembly 'Microsoft.Practices.EnterpriseLibrary.Data' does not have a strong name
Now like what you said i had tried
C:\MyWrapper\bin\Debug>dir
10/10/2006 02:09 PM 20,480 DbConnection.dll
10/11/2006 09:27 AM 16,384 DTS_Access.dll
10/11/2006 09:27 AM 15,872 DTS_Access.pdb
12/17/2002 06:23 PM 131,072 Interop.DTS.dll
09/15/2006 02:07 PM 57,344 Microsoft.Practices.EnterpriseLibrary.Com
mon.dll
09/15/2006 02:07 PM 118,784 Microsoft.Practices.EnterpriseLibrary.Con
figuration.dll
09/15/2006 02:07 PM 86,016 Microsoft.Practices.EnterpriseLibrary.Dat
a.dll
10/11/2006 09:35 AM 596 MyKeyPair.snk
03/12/2006 03:45 PM 73,728 NCI.EasyObjects.dll
11/29/2005 12:44 AM 145,755 NCI.EasyObjects.xml
C:\MyWrapper\bin\Debug>tlbimp NCI.EasyObjects.dll /delaysign /publi
ckey:MyKeyPair.snk /out:Interop.NCI.EasyObjects.dllMicrosoft (R) .NET Framework Type Library to Assembly Converter 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.
TlbImp error: The input file 'C:\MyWrapper\bin\Debug\NCI.EasyObject
s.dll' is not a valid type library
C:\MyWrapper\bin\Debug>tlbimp Microsoft.Practices.EnterpriseLibrary
.Data.dll /delaysign /publickey:MyKeyPair.snk /out:Interop.Microsoft.Practices.
EnterpriseLibrary.Data.dllMicrosoft (R) .NET Framework Type Library to Assembly Converter 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.
TlbImp error: The input file 'C:\MyWrapper\bin\Debug\Microsoft.Prac
tices.EnterpriseLibrary.Data.dll' is not a valid type library
Bascilly why am i getting "is not a valid type library" error. Please help. How would i be able to strong name those dll's which are 3rd party.
|
|
|
|
|
Ok I found it, basically i went to the source code for each dll i was refering and then strong named it myself and compiled. Now the pain is any other dll referenced by those dlls also have to be strong named.....
But finally got the result.
thanks...
|
|
|
|
|
Anybody have any good examples of how to do this with a complex structure? This is a breeze using just straight XML, along with a few classes to represent your data in code, but using .NET 2's ConfigurationSection class and the various related attributes appears to be a royal pain in the arse for anything but simple configs. I also heard that IConfigurationSectionHandler is being obsoleted, so I probably shouldn't go down that route, either. Here's a sample of the XML format I want as an example of what I'm trying to accomplish:
<?xml version="1.0" encoding="utf-8" ?>
<EventLogger>
<Loggers>
<DbErrorLogger Name="DbLogger" Type="Integra.Logging.DbErrorLogger">
<ConnectionString>some connection string</ConnectionString>
<CommandTimeout>60</CommandTimeout>
<CommandType>StoredProcedure</CommandType>
<CommandText>uspSomeProc</CommandText>
</DbErrorLogger>
<EmailLogger Name="EmailLogger1" Type="Integra.Logging.EmailLogger">
<Recipients>
<To>nordyj2001@yahoo.com</To>
<!--<CC></CC>-->
<!--<BCC></BCC>-->
</Recipients>
<InfoSubject>Information</InfoSubject>
<WarningSubject>Warning</WarningSubject>
<ErrorSubject>Error</ErrorSubject>
<Server>mail</Server>
<InfoBody/>
<WarningBody/>
<ErrorBody>
<![CDATA[
An error occurred running the service. Following is a description of the error:
Error Message: {!MESSAGE}
File: {!FILE}
Line Number: {!LINENUMBER}
]]>
</ErrorBody>
<Sender>sender@yahoo.com</Sender>
</EmailLogger>
</Loggers>
<LoggerProfiles>
< Profile Name="DBOnly">
<Logger Name="DbLogger"/>
</Profile>
< Profile Name="EmailOnly">
<Logger Name="EmailLogger1" />
</Profile>
< Profile Name="DbAndEmail">
<Logger Name="DbLogger" />
<Logger Name="EmailLogger1" />
</Profile>
</LoggerProfiles>
</EventLogger>
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan
Portland, Oregon, USA
|
|
|
|
|
What about serialization?
led mike
|
|
|
|
|
HEllo,
I would appreciate if anyone provide me a snippet to delete all non empty subfolders and files under a directory. I tried with Directory.Delete(..), but it allows only non empty directory and I am not sure if that will delete non empty sub folders too.
Thanks and regards
Emran
|
|
|
|
|
bashiwala wrote: delete all non empty subfolders and files under a directory.
HINT: "recursion"
led mike
|
|
|
|
|
Hi,
Thanks for the hint. But even using Recursion requires non empty directory, isn't it ? I want to delete all subfolders and files regardless they are empty or non empty.
Is there any easy way ?
|
|
|
|
|
bashiwala wrote: But even using Recursion requires non empty directory, isn't it ?
Sure it does, but the trick is that you recursively call your method for all current subfolders and delete them afterwards when everything inside was deleted. Here some pseudocode to get you an idea of the recursive function.
void delete(string directory)
{
delete all files in directory
for all subdirectories in directory
{
call delete with current subdirectory
delete the now empty subdirectory
}
}
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
bashiwala wrote: Is there any easy way ?
Q: What is "easier" than writing 10 or 20 or 200 lines of code?
A: Getting someone else to do it for you.
led mike
|
|
|
|