thanks for the reply....i actually was going about it wrong what i'm doing now (to my disguntlement) is keeping an arraylist of my objects in the session collection, and databinding to it...it's working fine i assumed that the ListBox.Items collection would hold objects (as long as they had a tostring() method), but i was wrong. you can, however databind to any object collection/list, as long as the tostring() method is provided, or a datavaluemember and datatextmember are specified michael griffith -------------------- mgriffith@lauren.com mdg12@po.cwru.edu
mgriffith
Posts
-
add object to listbox -
add object to listboxi have created a simple class and want to add it to a listbox using the overloaded tostring() method...i've seen this done in about 10 examples, and straight from msdn, but it's not working for me (using a System.Web.UI.WebControls.ListBox) even with a simple class: ------------------- | Public Class asdf | Public Overrides Function ToString() As String | Return "asdf" | End Function | End Class ------------------- i try to call ------------------- | lstboxMyListBox.Items.Add(new asdf()) ------------------- or even ------------------- | cstr(new asdf()) ------------------- and it won't let it compile because: "Value of Type 'mynamespace.asdf' cannot be converted to 'String'" i then tried this: ------------------- | Public Class asdf | Public Overloads Overrides Property ToString() As String | Get | Return "asdf" | End Get | Set(ByVal Value As String) | | End Set | End Property | End Class ------------------- but i get an error compiling the class because: "'ToString' conflicts with a function by the same name declared in 'Object'" any ideas :~ michael griffith -------------------- mgriffith@lauren.com mdg12@po.cwru.edu
-
DataGrid Editing doesn't updatea couple of points... 1. you are using a global sqlconnection....this could hog resources...i'd at least try to close it after every use and reopen it before every use...the datagrid is good at displaying disconnected data (that's that the System.Data.DataSet object is) 2. make sure you aren't calling DataBind() in your page_load event every time, or else it'll grab the data right from sql again should be something like public void page_load() { if (!Page.IsPostBack) { Page.DataBind(); } else { //do nothing...page was posted back, and data will remain in datagrid unless changed in another function } } hope this helps :eek: michael griffith -------------------- mgriffith@lauren.com mdg12@po.cwru.edu
-
method executing too many timesi just asked this on the visual c++ forum, but i think this is probably a better place to ask....here goes nothing i have 2 methods that are using IWebBrowser2 to execute a print method from a com object that is hosted on a webpage. here is the code for the methods: --------------------------------- STDMETHODIMP CTemplatePrinter::IEPrintNoPrompt(VARIANT varTemplateURL) { CComPtr spContainer; CComPtr spSP; CComPtr spWB; CComPtr spDisp; CComPtr spDoc; CComPtr spCT; CComVariant vPTPath = varTemplateURL; m_spClientSite->GetContainer(&spContainer); spContainer->QueryInterface(IID_IServiceProvider, (void**)&spSP); spSP->QueryService(SID_SWebBrowserApp, IID_IWebBrowser, (void**)&spWB); spWB->get_Document(&spDisp); spDisp->QueryInterface(IID_IHTMLDocument2, (void**)&spDoc); spDoc->QueryInterface(IID_IOleCommandTarget, (void**)&spCT); // ******* THIS IS WHERE IT'S GOING CRAZY!!!! ******* // spCT->Exec(&CGID_MSHTML, IDM_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, &vPTPath, NULL); return S_OK; } --------------------------------------- STDMETHODIMP CTemplatePrinter::IEPrint(VARIANT varTemplateURL) { CComPtr spContainer; CComPtr spSP; CComPtr spWB; CComPtr spDisp; CComPtr spDoc; CComPtr spCT; CComVariant vPTPath = varTemplateURL; m_spClientSite->GetContainer(&spContainer); spContainer->QueryInterface(IID_IServiceProvider, (void**)&spSP); spSP->QueryService(SID_SWebBrowserApp, IID_IWebBrowser, (void**)&spWB); spWB->get_Document(&spDisp); spDisp->QueryInterface(IID_IHTMLDocument2, (void**)&spDoc); spDoc->QueryInterface(IID_IOleCommandTarget, (void**)&spCT); // ***** IT CALLS THIS 2 TIMES? ******** // spCT->Exec(&CGID_MSHTML, IDM_PRINT, OLECMDEXECOPT_PROMPTUSER, &vPTPath, NULL); return S_OK; } -------------------------- my question is: does anyone have any idea why the IOleCommandTarget::Exec method it going berzerk? when i call the method from a script, the first one keeps spooling pages into the printer, and the second one opens 2 print dialogs in a row...i also have another function for opening a print preview window that works fine....the only difference is my call to Exec is as follows: spCT->Exec(&CGID_MSHTML, IDM_PRINTPREVIEW, OLECMDEXE
-
method executing too many timesi have 2 methods that are using IWebBrowser2 to execute a print method from a com object that is hosted on a webpage. here is the code for the methods: --------------------------------- STDMETHODIMP CTemplatePrinter::IEPrintNoPrompt(VARIANT varTemplateURL) { CComPtr spContainer; CComPtr spSP; CComPtr spWB; CComPtr spDisp; CComPtr spDoc; CComPtr spCT; CComVariant vPTPath = varTemplateURL; m_spClientSite->GetContainer(&spContainer); spContainer->QueryInterface(IID_IServiceProvider, (void**)&spSP); spSP->QueryService(SID_SWebBrowserApp, IID_IWebBrowser, (void**)&spWB); spWB->get_Document(&spDisp); spDisp->QueryInterface(IID_IHTMLDocument2, (void**)&spDoc); spDoc->QueryInterface(IID_IOleCommandTarget, (void**)&spCT); // ******* THIS IS WHERE IT'S GOING CRAZY!!!! ******* // spCT->Exec(&CGID_MSHTML, IDM_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, &vPTPath, NULL); return S_OK; } --------------------------------------- STDMETHODIMP CTemplatePrinter::IEPrint(VARIANT varTemplateURL) { CComPtr spContainer; CComPtr spSP; CComPtr spWB; CComPtr spDisp; CComPtr spDoc; CComPtr spCT; CComVariant vPTPath = varTemplateURL; m_spClientSite->GetContainer(&spContainer); spContainer->QueryInterface(IID_IServiceProvider, (void**)&spSP); spSP->QueryService(SID_SWebBrowserApp, IID_IWebBrowser, (void**)&spWB); spWB->get_Document(&spDisp); spDisp->QueryInterface(IID_IHTMLDocument2, (void**)&spDoc); spDoc->QueryInterface(IID_IOleCommandTarget, (void**)&spCT); // ***** IT CALLS THIS 2 TIMES? ******** // spCT->Exec(&CGID_MSHTML, IDM_PRINT, OLECMDEXECOPT_PROMPTUSER, &vPTPath, NULL); return S_OK; } -------------------------- my question is: does anyone have any idea why the IOleCommandTarget::Exec method it going berzerk? when i call the method from a script, the first one keeps spooling pages into the printer, and the second one opens 2 print dialogs in a row...i also have another function for opening a print preview window that works fine....the only difference is my call to Exec is as follows: spCT->Exec(&CGID_MSHTML, IDM_PRINTPREVIEW, OLECMDEXECOPT_PROMPTUSER, &vPTPath, NULL); i've tried all that i can see...if i replace spCT->Exec(...) with spWB->ExecWB(