|
(This application is a Pocket PC application)
I have the following problem:
I create a dataset in code and add some rows to it. Then i show these rows using a datagrid.
<br />
<br />
DataSet ds = new DataSet("dataset");<br />
DataTable mytable = new DataTable("vizite");<br />
DataRow dr1, dr2;<br />
<br />
DataColumn dc = new DataColumn("bifat1");<br />
dc.Caption = "bifat1";<br />
dc.DataType = System.Type.GetType("System.Boolean");<br />
<br />
DataColumn dc2 = new DataColumn("bifat2");<br />
dc.Caption = "bifat2";<br />
dc.DataType = System.Type.GetType("System.Boolean");<br />
<br />
mytable.Columns.Add(dc);<br />
mytable.Columns.Add(dc2);<br />
<br />
<br />
dr1 = mytable.NewRow();<br />
dr1["bifat1"] = true;<br />
dr1["bifat2"] = false;<br />
mytable.Rows.Add(dr1);<br />
<br />
dr2 = mytable.NewRow();<br />
dr2["bifat1"] = true;<br />
dr2["bifat2"] = false;<br />
mytable.Rows.Add(dr2);<br />
<br />
ds.Tables.Add(mytable);<br />
<br />
dataGrid1.DataSource = ds.Tables["vizite"];<br />
<br />
This part works the way it should it shows:
+----------+
|True|False|
+----+-----+
|True|False|
+----+-----+
After this i want to change in the dataset all "True" values to "Yes" and all "False" values to "No".
This is how i wanted to do it:
<br />
<br />
int i;<br />
<br />
for (i=0;i<ds.Tables["vizite"].Rows.Count;i++)<br />
{<br />
object cell = null;<br />
string cellstr;<br />
<br />
cell = ds.Tables["vizite"].Rows[i].ItemArray[0];<br />
cellstr = System.Convert.ToString(cell);<br />
if (cellstr == "True")<br />
{<br />
ds.Tables["vizite"].Rows[i].ItemArray[0] = "yes";<br />
}<br />
if (cellstr == "False")<br />
{<br />
ds.Tables["vizite"].Rows[i].ItemArray[0] = "no";<br />
}<br />
<br />
cell = ds.Tables["vizite"].Rows[i].ItemArray[1];<br />
cellstr = System.Convert.ToString(cell);<br />
if (cellstr == "True")<br />
{<br />
ds.Tables["vizite"].Rows[i].ItemArray[1] = "yes";<br />
}<br />
if (cellstr == "False")<br />
{<br />
ds.Tables["vizite"].Rows[i].ItemArray[1] = "no";<br />
}<br />
<br />
}<br />
The problem is this code is not doing anything...i cant see the changes. The table is still the same
|
|
|
|
|
Hello,
What does the debugging tell you?
Is the code were you set a value to the Item excecuted?
If yes, maybe you only need a "Refresh()" or "Invalidate()" of the control.
Apart from that:
Use "else if".
string.Equals
Don't always access an Item over the whole Indexer structure (Row actRow)
All the best,
Martin
P.S.:
Just saw that it is your first post here on the forum.
Your question is detailed and has a good subject statement! (But you should use the "pre" Tag for code snippets)
Got my '5' to say: Wellcome!
|
|
|
|
|
The code inside the if is executing i've checked when i debugged the program.
The instructions inside these 'if's are executing as they should
<br />
if (cellstr == "True")<br />
{<br />
ds.Tables["vizite"].Rows[i].ItemArray[0] = "yes";<br />
}<br />
if (cellstr == "False")<br />
{<br />
ds.Tables["vizite"].Rows[i].ItemArray[0] = "no";<br />
}<br />
<br />
cell = ds.Tables["vizite"].Rows[i].ItemArray[1];<br />
cellstr = System.Convert.ToString(cell);<br />
if (cellstr == "True")<br />
{<br />
ds.Tables["vizite"].Rows[i].ItemArray[1] = "yes";<br />
}<br />
if (cellstr == "False")<br />
{<br />
ds.Tables["vizite"].Rows[i].ItemArray[1] = "no";<br />
}<br />
I really don't know what the problem is!
I've tried with this.refresh and this.update too...well i'll try with invalidate too. though i have a feeling it wont work.
...
It doesn't.
|
|
|
|
|
|
This doesn't work either. I don't think that i get no changes because i need to make refreshes.. but i don't know what else should i do or what am i doing wrong.
-- modified at 8:17 Monday 9th July, 2007
|
|
|
|
|
sorry!! i didn't see your code.there are two mistakes.
1. Firstly when you added Column you specified their Type as Boolean and now u r changing the values.
2.when you assign the data source property with out making any table style structure it automatically generate table style for it.
put DataGrid1.TableStyles.Clear() before reassigning data source and then use refresh
|
|
|
|
|
I forgot to mention that i tried with "System.String" too instead of "System.Boolean" but it didn't work either.(used both true as boolean and "true" as string) I'm sorry but i didn't quite understand where should i put that DataGrid1.TableStyles.Clear(). After i add the rows to the dataset and before the 'for' cicle.
|
|
|
|
|
hmm.. i think some part is missing. check the following code .its working fine.in case any confusion please feel free for messaging me
DataSet ds = new DataSet("dataset");
System.Data.DataTable mytable = new System.Data.DataTable("vizite");
//fill data in grid
private void fillGrid()
{
DataRow dr1, dr2;
DataColumn dc = new DataColumn("bifat1");
dc.Caption = "bifat1";
//dc.DataType = System.Type.GetType("System.Boolean");
DataColumn dc2 = new DataColumn("bifat2");
dc.Caption = "bifat2";
//dc.DataType = System.Type.GetType("System.Boolean");
mytable.Columns.Add(dc);
mytable.Columns.Add(dc2);
dr1 = mytable.NewRow();
dr1["bifat1"] = "True";
dr1["bifat2"] = "False";
mytable.Rows.Add(dr1);
dr2 = mytable.NewRow();
dr2["bifat1"] = "True";
dr2["bifat2"] = "False";
mytable.Rows.Add(dr2);
ds.Tables.Add(mytable);
dataGrid1.DataSource = ds.Tables["vizite"];
}
///
/// changes values of grid
///
private void changeValues()
{
for (int i = 0; i < mytable.Rows.Count; i++)
{
if (mytable.Rows[i][0].ToString() == "True")
{
mytable.Rows[i][0] = "yes";
}
if (mytable.Rows[i][1].ToString() == "True")
{
mytable.Rows[i][1] = "yes";
}
}
dataGrid1.Refresh();
}
|
|
|
|
|
Hi
I wrote an aplication using C# that works with Sql Server 2000 and it works right in my computer but when i wanna run it on other computer in my lan (that intalled .NET framework on it) there is an error in accessing to database and when i installed Visual Studio.NET2005 on this computer my application worked right!
So it apears that needs some library to run my application to access sql server.
(when i run my application until using database it works right and problem is in accessing to sql server)
the connection string is complete with user id and password and name of sql server.
please help me
|
|
|
|
|
|
Hi
I wrote an aplication using C3 that works with Sql Server 2000 and it works right in my computer but when i wanna run it on other computer in my lan (that intalled .NET framework on it) there is an error in accessing to database and when i installed Visual Studio.NET2005 on this computer my application worked right!
So it apears that needs some library to run my application to access sql server.
(when i run my application until using database it works right and problem is in accessing to sql server)
the connection string is complete with user id and password and name of sql server.
please help me
|
|
|
|
|
What is the error that occurs?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi All
i am accessing a webservice in my local machine through application which is of c# code and using XMLHTTP40 class
i have condition to check the status of the XMLHTTP40 .i created the object of it and was checking a condition like below
if (objXmlHTTP.status != 200)
{
}
i am getting status value as 500 .Why status is giving me 500 . i restarted my webservice and then restarted my machine but still status value is 500. can any one help me.
Advanced thanks
Regards
DilipRam
|
|
|
|
|
Have a look in your event logs and see if there are any IIS events written there. Status 500 is the catch all "something is wrong with the server" error, so without more information there is little we can help you with.
|
|
|
|
|
Hi Thanks for responding
when i checked the event log
i found entries like this
11:07:29 127.0.0.1 GET /_vti_bin/owssvr.dll 500
11:07:29 127.0.0.1 GET /MSOffice/cltreq.asp 404
11:07:29 127.0.0.1 POST /xmlsportsin/xmlsportsin.asmx 500
11:09:21 127.0.0.1 POST /xmlsportsin/xmlsportsin.asmx 500..
i looked the log file in the following path
C:\WINNT\system32\LogFiles\W3SVC1...in my local machine.
Any idea.
Regards
DilipRam
|
|
|
|
|
You also get the Text response in responseText. Check the property name anyway.
|
|
|
|
|
Hi
Thanks.I got the error from the response text and i fix the problem
Thanks
Regards
DilipRam
|
|
|
|
|
Hi!
Anybody knows how to insert checkbox into a datagrid in Device Application NOT in ASP.NET!!??
Thanks!
Marta Paniti
--------------------------------
visit: http://pmartike.deviantart.com/
|
|
|
|
|
hi
add a checkbox to the form and in the click event on the datagrid read the positions of the datagrid cell.
set the position of the checkbox to the values read.
Regards
Bharath S
Bharath.S Ron
|
|
|
|
|
mhmm.. other method?
--------------------------------
visit: http://pmartike.deviantart.com/
|
|
|
|
|
Hi,
if you are using .Net 2.0 (V.S. 2005) then use DataGrid View checkbox column is already present there.O/W you have to implement custom grid.
|
|
|
|
|
I'm using Compact Framework because the program is for PocketPc. And there is no DataGridView...
--------------------------------
visit: http://pmartike.deviantart.com/
|
|
|
|
|
then implement your custom data grid and add column in the table style. a little tricky but a little search gonna help alot
|
|
|
|
|
Hiya all,
Is it good practice to use NUnit Testing..??
What are the advantage n disadvantage of using Nunit testing.. Well i dont think its good if the application is not that big.
Anyway i would like to know the experienced developers comment on this....
Thanks
|
|
|
|
|
It's unit testing with NUnit and not NUnit testing. (A subtle, but important distinction because there are other unit testing frameworks). This is a large topic, and I will attempt to give you a succinct answer which explains why I use it on all projects.
NUnit (and other frameworks) allow you to write repeatable tests. If you change your code, simply rerun the tests and check that you get the correct values. This all depends, of course, on your unit tests actually testing your code effectively.
Now, this is all well and good, but where NUnit (and the other frameworks) comes into its own is with Test Driven Development (TDD). This approach means that you write unit tests before you actually write the code. You then build up your code and unit tests little bit by little bit until you can prove that the code works properly.
|
|
|
|