|
|
I have a variable number of DropDownList controls inside a Datalist control. This variability depends of the number of records in a DataTable.
I would be grateful if someone could tell me how to create ListItem controls accordingly with the data contained in a DataTable.
Here are the 4 possible ListItem controls to be inserted:
<asp:ListItem Value="blue" >Blue</asp:ListItem>
<asp:ListItem Value="red" >Red</asp:ListItem>
<asp:ListItem Value="black" >Black</asp:ListItem>
<asp:ListItem Value="white" >white</asp:ListItem>
For instance, if a product is manufactured with one of two colors ( let’s say “red” and “white” ) then the DataTable contains these binary values: “false”, “true”,”false”,”true” or ( 0,1,0,1) in the parameters “showBlue”, “showRed”, “showBlack”, “showWhite” for the four ListItem controls. So, in this example, I would want to use these data to create only ListItem controls for the red and the white options.
How do that ?
Here are the relevant pieces of code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<asp:DataList ID="ProductsList" Runat="server" EnableViewState="False" Visible="false" >
<ItemTemplate>
. . .
<span class="Title">
Product: <%# Eval("Title") %>
</span>
</td>
</tr>
<tr>
<td align="center" width="250">
<span class="Colors">
<asp:DropDownList ID="ColorsList" OnSelectedIndexChanged="GetColor" runat="server">
</asp:DropDownList>
</span>
</td>
</tr>
. . .
</ItemTemplate>
</asp:DataList>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
protected void InsertDataInDataList()
{
ProductsList.DataSource = UserAccess.UserProducts(Username);
ProductsList.DataBind();
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Obs: The “UserAccess.UserProducts(Username)” method returns a DataTable with variable number of records.
|
|
|
|
|
hi
i was installed sqlServer 2005 management Studio Express on my Server and i want to connect from my app (in other computers) to this database,but when i want add datasource to my project and select Microsoft SqlServer and inter Server's Name + "\SQLEXPRESS", i can not connect to database's, and i don't know where does the problem.
can anybody show me how to solve this problem ?
thanks
|
|
|
|
|
hdv212 wrote: i was installed sqlServer 2005 management Studio Express on my Server and i want to connect from my app (in other computers) to this database
That is not a database server, that is a graphic interface to manage an SQL Server 2005 database server. If you want to connect to the database server you have to install the actual database server also.
---
b { font-weight: normal; }
|
|
|
|
|
Did you actually install the database itself?
|
|
|
|
|
This is a very complex question, so please bare with me.
I'm using VB.net and C# (both vs2003), on a Windows XP machine.
First off, I have some code that allows me to retrieve an IRichEditOle object from a rich text box. With this object, I can insert an object into a RichTextBox control. After inserting the object(s), I can then call GetObjectCount and GetObject to iterate through the Ole objects embedded within the RichTextBox. The code for retrieving the RichEditOle interface and for inserting and retrieving objects (the meat of the application) is written in C#.
I have also written a custom control that inherits from "System.Windows.Forms.Label" and also implements IOleObject. This code is in VB.NET. It is registered for COM Interop and the appropriat guids have been generated. Besides the basic Label functionality, it also eposes extra public properties (strings).
The idea is that a user would be able to insert this custom label control anywhere within a RichTextBox. It works. I can insert and remove multiple controls. I can iterate through the collection of controls in the RichTextBox, cast them back to the custom label, and access each of their properties. It seems to be working perfect.
However, when I save the RTF, and then try to reload, I completely lose the embedded information. Everything else is there, just no custom labels in the RichTextBox. I can open the RTF in Notepad and see that there is embedded information. It saved, but didn't load.
I'm thinking that at least part of my problem might be that I'm not implementing the correct interfaces to allow the custom label to persist itself within the RTB. It might also be that I'm not inserting the object correctly within the RTB. The insertion part is fairly straightforward though. I have a REOBJECT class that I populate and pass to the IRichEditOle::InsertObject(REOBJECT re) method
Here's some of the code:
using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.OLE.Interop;
[StructLayout(LayoutKind.Sequential)]
public class REOBJECT
{
public int cbStruct = Marshal.SizeOf(typeof(REOBJECT)); // Size of structure
public int cp; // Character position of object
public Guid clsid; // Class ID of object
public IntPtr poleobj; // OLE object interface
public IStorage pstg; // Associated storage interface
public IOleClientSite polesite; // Associated client site interface
public Size sizel; // Size of object (may be 0,0)
public uint dvAspect; // Display aspect to use
public uint dwFlags; // Object status flags
public uint dwUser; // Dword for user's use
}
Then, the code for actually inserting (lots omitted for brevity):
ILockBytes pLockBytes;
CreateILockBytesOnHGlobal(IntPtr.Zero, true, out pLockBytes);
IStorage pStorage;
StgCreateDocfileOnILockBytes(pLockBytes, (uint)(STGM.STGM_SHARE_EXCLUSIVE|STGM.STGM_CREATE|STGM.STGM_READWRITE), 0, out pStorage);
IOleClientSite pOleClientSite;
this.IRichEditOle.GetClientSite(out pOleClientSite);
Guid guid = new Guid();
oleObject.GetUserClassID(out guid);
OleSetContainedObject(oleObject, true);
REOBJECT reoObject = new REOBJECT();
reoObject.cp = this._richEdit.SelectionStart;
reoObject.clsid = guid;
reoObject.pstg = pStorage;
reoObject.poleobj = Marshal.GetIUnknownForObject(oleObject);
reoObject.polesite = pOleClientSite;
reoObject.dvAspect = (uint)DVASPECT.DVASPECT_CONTENT;
reoObject.dwFlags = (uint)REOOBJECTFLAGS.REO_BELOWBASELINE;
this.IRichEditOle.InsertObject(reoObject);
Marshal.ReleaseComObject(pLockBytes);
Marshal.ReleaseComObject(pOleClientSite);
Marshal.ReleaseComObject(pStorage);
}
Any help in solving this is GREATLY appreciated.
Thanks for looking,
Tony
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.
|
|
|
|
|
Looks like I've stumped the experts.
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.
|
|
|
|
|
|
Thanks for the article, however, it isn't really what I'm looking for.
It does show a media player control within the RTB and how to access it, but that's not what I need.
I have a custom control written in vb.net that I can already insert into a RTB. It seems like I save it ok, but when I reload the document, the controls are gone. The data in the RTF is stripped out during the load method of the RTB.
I need to be able to save the RTF with the embedded controls (and maintain their state), then reload the RTF later with all of the controls intact.
My best guess now is that my custom control isn't implementing the correct interfaces, or isn't getting registered correctly.
Any help is appreciated.
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.
|
|
|
|
|
Hi,
I needed a list view that was capable of showing multiple icons in the first column in details view. I managed to create this using owner draw and gdi+ and overall it was easy to do. The only problem I've run into is when the mouse cursor moves over a listview item for the first time, the listview attempts to redraw the item yet does not redraw any of the subitems.
This is an acknowledged bug with the control itself and is mentioned here: msdn library. The article also lists two workarounds, one of which isn't very effective, which I have tried. I was just wondering if anyone knew of another way to handle this issue?
Thanks.
|
|
|
|
|
Hi,
I find that I can drag an jpeg image from IE to MSWord document, but can't drag an image from IE to a c# window form which has already added with both the dragOver and dragDrop events. But I can drag an the image from MSWord document to the C# window form. Why ?
Summary for dragging and dropping jpeg image
1. from IE to C# window form : failed
2. from IE to MSWord : OK
3. from MSWord to C# Window form : OK
Thanks
|
|
|
|
|
What is the code in your DragDrop event?
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Thanks for ur reply.
The code for the drag drop is
void button1_DragDrop(object sender, DragEventArgs e)
{
object a = e.Data.GetData(DataFormats.Bitmap);
this.button1.Image = (Bitmap)a;
}
|
|
|
|
|
I looked into this a little. It seems that when you drag an image from MS Word, it is in fact a linked or embedded OLE Object. The data object contains a CF_EMBEDDEDOBJECT format that needs to be extracted using "standard OLE techniques". I've never done this before, sorry I can't really help you with it. However, this does explain why you are able to drag and drop images from IE to Word and Win Forms, but not Word to Win Forms.
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Has anybody done performance testing on the SqlBulkCopy class?
I'd assume that, like many classes that operate on bulk data, up to a certain point, doing individual SQL Insert statements (by enumerating and calling individual ExecuteNonQuery calls) will be more efficient than using SqlBulkCopy. But at some point, SqlBulkCopy will become more effiecient. In other words, something like this:
NumberOfRecords < M : Enumerated calls to ExecuteNonQuery is more efficient.
NumberOfRecords > M but < N : Doesn't matter which you use, as both are about the same.
NumberOfRecords > N : SqlBulkCopy more efficient.
Anybody know about what M and N would be? I did some Googling, but didn't come up with much in this regard.
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan
Portland, Oregon, USA
|
|
|
|
|
|
Hi, everybody!
My problem is that:
I have put in a dom node, representing an image, in a web page through c sharp, but how could I manage the click of the image?
I would like to bind the click event on the image to some work that I encapsulated insiede a c sharp method...but how could I bind the click event to some desired work? Am I to encapsulate thus work insiede an other language method? like javascript for example? but how if I'm writing a c sharp program?
I hope to have been rather clear, because I'm italian and I don't know if I explained my trouble good way, I hope so
thank yuou all in advance.
Lulaleila
|
|
|
|
|
Hey, wonder if any1 can help me, its a fairly simple issue to deal with so im told but ive spent ages trying to work this out, but havnt got anywhere. So was wondering if sum1 could lend a hand.
Basically ive an array of strings and i want to randomly select a word out of this array
Once the word is selected i then need to split the word into separate characters, so I can check the users input against each letter until they finally guess the word
I know it seems alot to ask, but id really appreciate it if sum1 could provide some example I could follow in order for me to get mine working...
Thanks in advance
Neptune
|
|
|
|
|
Random rand = new Random();
string[] somestrings = { "Hello", "World", "From", "An", "Array" };
string randString = somestrings[rand.Next(somestrings.Length - 1)];
char[] characters = randString.ToCharArray();
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Before you start writing an ounce of code, make sure you have a game plan (i.e. psuedocode or flowchart) that expresses your logic. Once you're fairly certain your logic is correct, it'll be pretty easy to convert it to C# (or any other language).
You could start by posting your logic and we'd be happy to help you refine/verify it.
/ravi
|
|
|
|
|
I would do something like this.
public bool isMatch()
{
bool Matches = false;
string[] asCompare = new string[4];
asCompare.SetValue("First0", 0);
asCompare.SetValue("Second1", 1);
asCompare.SetValue("Third2", 2);
asCompare.SetValue("Fourth3", 3);
Random ran = new Random();
int iVal = ran.Next(asCompare.Length - 1);
string sValue = asCompare[iVal];
char[] chars = sValue.ToCharArray();
string sCharTracker = "";
for (int i = 0; i < chars.Length; i++)
{
sCharTracker = chars[i].ToString();
//Matches = //you would probably do your compare with a method call here//
}
return Matches;//This will be if it matches or not//
}
|
|
|
|
|
neptune2k wrote: Basically ive an array of strings and i want to randomly select a word out of this array
Once the word is selected i then need to split the word into separate characters, so I can check the users input against each letter until they finally guess the word
That's a one-liner.
char[] chars = (new string[] { "some","words","in","an","array" })[(new Random()).Next(5))].ToCharArray();
---
b { font-weight: normal; }
|
|
|
|
|
thanks guys, thats really helped, i get where i was going wrong now
i know where to come in future if i hit any problems
|
|
|
|
|
I want to know how to copy,cut & paste the selected text in a text editor.
can any one help me in this please.
|
|
|
|
|
By "text editor" do you mean a TextBox ? If so, see this[^] link.
/ravi
|
|
|
|