|
It's pretty common to put the code to fill the data list in the Page_Load routine, and to place it inside an if (!IsPostBack) test since normally you only need to populate the control once, when the page loads. However, if you happen to have your population code inside this test for your particular situation, it wouldn't repopulate the control on the postback because it's explicitly told not to.
Don't know if this is how you have your code structured, but if it is, your fix may be as simple as moving the code outside the test so that it executes on every invocation of Page_Load, postback or not.
Hope this helps...
|
|
|
|
|
I am trying to use a WinForms control from another thread. Unfortunately, I can't use Control.Invoke directly, because the control calling code is hidden:
A Worker Thread modifies a DATA class. This fires an Event caught by a CONTROLLER class, which in turn tries to update a TreeView.
This doesn't work because the Node update is called from a worker thread.
(I am trying to feed my Generic Tree[^] in a worker thread)
Is there a way around it? Or do I have to change all calls in the controller to Invokes to delegates?
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
Linkify! || Fold With Us! || sighist
|
|
|
|
|
Peterchen, have you looked at the System.Windows.Forms.WindowsFormsSynchronizationContext class? Here's what you could do: let your controller class be constructed with a SynchronizationContext, then whenever you need to update the tree view, do so using the sync context. It'd look something like this:
class Controller
{
SynchronizationContext eventRaisingContext;
...
public Controller(SynchronizationContext context)
{
eventRaisingContext = context;
}
private void DataClassModifiedHandler()
{
eventRaisingContext.Post(UpdateTreeView);
}
void UpdateTreeView(object state)
{
}
}
Then, simply construct the Controller from the UI thread, like this:
Controller myController = new Controller(WindowsFormsSynchronizationContext.Current);
|
|
|
|
|
That surely gets me started... actualyl using it wasn't that bad. Only it's terribly slow, and exposes a weakness in my tree control feeder... back to the drawing board.. Anyway, thanks!
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
Linkify! || Fold With Us! || sighist
|
|
|
|
|
Ok. FYI, not sure that it matters since you're going back to the drawing board, but the SynchronizationContext.Post and SynchronizationContext.Send will boil down to Control.BeginInvoke and Control.Invoke for a WindowsFormsSynchronizationContext; shouldn't be much overhead in using SynchronizationContext.Send/Post versus using Control.Invoke/BeginInvoke.
|
|
|
|
|
feels a bit dumb to ask...
How do I test for a bit in an enum?
All examples I find combine enum values with an | - but how to check for a bit (what you do in C++ with &). (int) value & (int) flag works but that doesn't look elegant...
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
Linkify! || Fold With Us! || sighist
|
|
|
|
|
protected void mouseMoved(object sender, MouseEventArgs e) {
if ((e.Button & MouseButtons.Left)!=0) {
// ...
} else if ((e.Button & MouseButtons.Right)!=0) {
// ...
}
}
Luc Pattyn
|
|
|
|
|
I forgot the parantheses around the (a & b) ... thanks!
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
Linkify! || Fold With Us! || sighist
|
|
|
|
|
The enum really should have the [Flags] attribute, which tells the compiler that all of the values are supposed to be unique and provides a few other subtle runtime differences.
The best way to test to see if a particular value has been set is:
FileInfo info = new FileInfo(@"c:\windows\explorer.exe");
if ((info.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
{
}
else
{
} .NET does allow you to treat an enum without the [Flags] attribute as if it were a flags enum to some extent, but it isn't recommended. If at some point the language or the compiler rules change, using an enum in this way without the [Flags] attribute could generate a compiler warning or error.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
I can display results of a view I created in Sql server on a dataGrid,how would I display the same result on a txtBox ???
aPerfectTool
|
|
|
|
|
Hi
I think you want to access database tables field to show in textbox.
If below code is not your answer contact me:
SqlConnction cnn = new SqlConnection("Data Source=YourCopmputerName;Initial Catalog=YouDatabaseName;User Id=databaseUserName;Password=DatabasePassword");<br />
string strSql="SELECT id,name FROM Table1";<br />
DataSet ds = new DataSet();<br />
SqlDataAdapter da = new SqlDataAdapter(strSql,cnn);<br />
da.fill(ds,"Table1");<br />
if (ds.Tables[0].Rows.Count != 0)<br />
{<br />
TextBox1.Text = ds.Tables[0].Rows[0][1].toString();<br />
}<br />
This code get "name" column of tables from first row. you can access another cells by changing array index.
Bye
|
|
|
|
|
Hi,
I think U can achieve this in two ways.
1) Command.Text = "SELECT * FROM UR View Name (Nested of Table Name)"
2) Create one store Proc, Let the Store Proc intern selects view data by executing SELECT * FROM UR View Name.
For binding and displaying on Data Grid follow normal method.
Happy Coding
Gowda
|
|
|
|
|
Thanks guys, I got it going, your reponse helped me alot
aPerfectTool
|
|
|
|
|
hi
i want to write database application with c# 2005 and i want to set password to sqlserver 2005 database that users can not access to tables,views,....
but .. how to do ??
thanks
|
|
|
|
|
Hi
You can do this in the target system which you want to install your program on it.
But anybody can stop the sqlserver and take a copy of your database and then attach it to his/her sqlserver on another system without knowing username and password!!
I want to say it's not a cool way.
Do this to set a password to your database:
1-Open SqlServer and in Object explorer expand Security\Logins
2-Right Click and Logins and choose "New Login..."
3-In Login - New window type a LoginName and choose "Sql Server Authentication" and type password and uncheck checkboxes unless "Enforce password Policy" and Click "Ok "
4-Delete "BUILTIN\Administrator"
Now you have set password to sqlServer 2005
To set database password:
1-Expand your database and goto Security\Users
2-Right click on Users and select "New User..."
3-Type username and for import user click on button "..." front of "Login Name" and browse your user
4-Choose "db_owner" from below listbox
5-Press ok
I wish this is usefull
For more information goto:
http://forums.microsoft.com/MSDN/showpost.aspx?postid=672105&siteid=1[^]
This was my question in Msdn forum
Bye
|
|
|
|
|
main points to keep in mind in making chess in c#.
rao nasir ali khan
|
|
|
|
|
|
Excellent answer !!
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello,
I am using properties from Properties.Settings.Default.* in my background worker thread. I was wondering if they are thread safe or not ? moreover if two threads try to read the same settings value at the same time, (NOT WRITE, just READ) is there any chance that my application will crash throwing exception ?
Thanks
|
|
|
|
|
Any shared resource that is read-only (that is, no threads are writing to the resource) is inherently thread safe. So unless you've got another thread writing to the settings, yes, 2 background threads reading the settings is safe.
|
|
|
|
|
Hi.
Thanks for your reply.
Regards
|
|
|
|
|
My application accepts single string databaseaddress.
I think the best form for this is
servername:port/databasename
parts other than servername may be missing. So legal forms are also
servername
servername:port
servername/databasename
samples:
143.44.454.45:33/mydb
myhost@mycomp.com
myhost@mycomp.com/mydb
How to extract servername, port and databasename to separate variables ?
servername, port and databasename does not contain : and / characters.
There is no need for syntax check.
|
|
|
|
|
I think System.Uri.TryCreate method will work for you.
|
|
|
|
|
i am working on a Point of sales application in C#. I want to redirect the values to the pos device connected to LPT1. Can anyone tell me how i can do this.
Thanks for your help
Regards
Hari
rkharikrishnan.bizhat.com
|
|
|
|
|
Isn't LPT1: just printing it?
|
|
|
|