|
ali zaidi wrote: now on client machine it shuld be updated it self
Not unless you have written some code in your app to do it. Google for .net deployment, there are loads of articles showing the problems and pitfalls.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi All,
Can anyone tell me wat im doing wrong...im trying to populate a treeview from sql with a foreach loop...my code is like this..
foreach (DataRow dr in dt.Tables)<br />
{<br />
<br />
}<br />
Please tell me wat im doing wrong?
living life on the flip side
|
|
|
|
|
if dt is a DataSet then dt.Tables is a collection of Table s, not DataRow s. If dt is a DataTable (as the name suggests) you want dt.Rows
|
|
|
|
|
thanks alot...works like a bomb...thanks to all
living life on the flip side
|
|
|
|
|
ok thanks for your help but now i have another question...im trying to add subchild nodes to childnodes... my code
ListItem lstItem = new ListItem();
foreach (DataRow row in dt.Rows)
{
TheNode13.Text = "";
lstItem.Value = row["ID"].ToString();
lstItem.Text = row["Name"].ToString();
TheNode13.Text = lstItem.Text;
TheNode13.Value = lstItem.Value;
TheNode12.Nodes.Add(TheNode13);
}
everytime i add them then it overwrites the subchildnode and add the same node twice...wat am i doing wrong?
living life on the flip side
|
|
|
|
|
You need to instantiate a new TreeNode each time.
|
|
|
|
|
try dt.Tables[0].Rows
rahul
|
|
|
|
|
foreach (DataRow dr in dt.Tables.Rows)
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
I'm busy working on some user controls...
these are made up of 2 panels on which data is drawn using GDI+ in the form of time lines and clocks. On the time lines i have maskedTextBoxes with the mask "##:##" and in turn shows up as "__:__" when empty.
In the TextChangedEventHandler of each maskedTextBox I try to parse the value to a DateTime property, so if the user input is a valid time the corresponding property to the maskedTextBox is set.
Also in the TextChangedEventHandler the method DrawData() is called which sets some private bool's when certain groups of these DateTime properties are filled in correctly. Ex if the start and stop time of a break is filled in as 09:00 and 09:30 a pie will be drawn behind the clock representing the break.
so far so good. The irritation sits in the containing forms designer code. As per a different thread monday(i think) i noticed my properties set block was getting executes BEFORE the user enteres text in the MaskedTextBoxes. So upon construction of the control all my MaskedTextBoxes had "00:00" in them instead of "__:__".
It was later discovered that the containing form initailizes the properties in its designer code which was executing my set blocks.
as a work around i did the following...
private DateTime postEnd = new DateTime();
public DateTime PostEnd
{
get
{
return postEnd;
}
set
{
postEnd = value;
if (postEnd != new DateTime())
{
mtxtPostEnd.Text = postEnd.TimeOfDay.ToString();
}
}
}
this was working but only for a few of the properties, the others was STILL SHOWING "00:00"
i went screwing around in the designer code again and this is what i found...
this.breakClockControl3.AfterTime = System.TimeSpan.Parse("00:00:00");
this.breakClockControl3.BreakEnd = new System.DateTime(((long)(0)));
this.breakClockControl3.BreakStart = new System.DateTime(((long)(0)));
this.breakClockControl3.BreakType = "Windo";
this.breakClockControl3.Dock = System.Windows.Forms.DockStyle.Fill;
this.breakClockControl3.Duration = System.TimeSpan.Parse("00:00:00");
this.breakClockControl3.Location = new System.Drawing.Point(3, 3);
this.breakClockControl3.Name = "breakClockControl3";
this.breakClockControl3.PostEnd = new System.DateTime(2008, 7, 17, 0, 0, 0, 0);
this.breakClockControl3.PostGrace = System.TimeSpan.Parse("00:00:00");
this.breakClockControl3.PostRound = System.TimeSpan.Parse("00:00:00");
this.breakClockControl3.PreGrace = System.TimeSpan.Parse("00:00:00");
this.breakClockControl3.PreRound = System.TimeSpan.Parse("00:00:00");
this.breakClockControl3.PreStart = new System.DateTime(2008, 7, 17, 0, 0, 0, 0);
this.breakClockControl3.ShiftEnd = new System.DateTime(2008, 7, 17, 0, 0, 0, 0);
this.breakClockControl3.ShiftStart = new System.DateTime(2008, 7, 17, 0, 0, 0, 0);
this.breakClockControl3.Size = new System.Drawing.Size(486, 317);
this.breakClockControl3.TabIndex = 0;
as you can see some of the DateTime's are initialized as new System.DateTime(((long)(0))); which is perfect and others like new System.DateTime(2008, 7, 17, 0, 0, 0, 0); which screws up my work around
Why does the designer do this? i don't get it...
any ideas on what i can do?
thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
This is to do with DesignerSerialization. Look up on how to suppress properties, set defaults, visibility, etc.
|
|
|
|
|
thanx leppie
google here i come!
it just makes no sense to me that two of the exact same things gets initialized to two different values for no apparent reason, stupid MS...
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
i solved the issue by doing the following
private DateTime breakEnd = new DateTime();
[DefaultValue(typeof(DateTime), "00:00")]
public DateTime BreakEnd
{
get
{
return breakEnd;
}
set
{
breakEnd = value;
if (breakEnd != new DateTime())
{
mtxtBreakEnd.Text = breakEnd.TimeOfDay.ToString();
}
}
}
i just hope it holds up...
thanx again for pointing me in a direction
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
HarveySaayman wrote: i just hope it holds up...
Why? Your dev station a bit unpredictable?
|
|
|
|
|
no, but Visual Studio is
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
I was thinking about this more the other day but haven't had chance to try any code so I haven't reposted. The problem lies in the public properties that the form must set (to zero or the equivalent). If you made the properties private remove the properties but created public methods to set/get them the private member variables (sort of what a property does internally anyway) then the form wouldn't automatically mess with the values - only when it was instructed to call the methods.
Dave
|
|
|
|
|
hi
i'm working on hiding data in structure of microsoft word document 2003
my problem is how i access to document stream and table stream in strucutre of word
i think i must entring the root first
please help me
|
|
|
|
|
you can use IFilter that reads pure text of a document. It's amazing )
but I don't know how to reach that table stream
|
|
|
|
|
There is a method called datatable.select(string) to filter rows from a datatalbe
But the string must contains one columnname in the datatable.I know nothing about the datatable,what i want to get is just the first N rows in the datatable.
what should i do? Thanks
|
|
|
|
|
The DataTable's Rows property contains all the rows in the table. Just loop through it.
|
|
|
|
|
IEnumerable<DataRow> dt = myDataTable.AsEnumerable().Take(3);
Now, you have a new DataRow list
modified on Wednesday, July 16, 2008 7:06 AM
|
|
|
|
|
thanks,thank you very much!
accrooding your way i have solve my question.I could get the first 100Rows,
But another question is how do i get the second 100 rows(101-200)?
because i want to display 100rows/page.
thanks for any help.
|
|
|
|
|
if you thing to make paging you can use this:
Maybe it's a bit long way but I couldn't find another way.
for first 100 records:
IEnumerable<DataRow> dt = myDataTable.AsEnumerable().Take(100);
for next n * 100
IEnumerable<DataRow> dt = myDataTable.AsEnumerable().Skip(n * 100);
I meant if someone clicked 5. page
n=5
IEnumerable<DataRow> dt1 = myDataTable.AsEnumerable().Skip(n * 100);
than you need new table with your new rows (dt1)
your secondTable = dt1
after that again
IEnumerable<DataRow> dt2 = secondTable.AsEnumerable().Take(100);
I hope it's helpfull
modified on Friday, July 25, 2008 8:31 AM
|
|
|
|
|
Thank you very much!i will try.
Thank you!
|
|
|
|
|
Hi all,
How do i know that there is some row exist in the grid or not ...
i have to test a condition like
if(this.abcgridview.CurrentRow.selected)
{
// do something
}
am calling this condition from two different places
in first case grid has some rows..that time no problem am able to execute my task
but in second one i dont have anyvalue in the grid that time it is throwing me error message ...
like "Object reference not set to an instance of an object".
can you please help me here ...
Thank you..
vikas da
|
|
|
|
|
if(dataGridView1.Rows[0].Cells[0].Value.GetType() == typeof(DBNull))
{
}
|
|
|
|