|
There is no built in function for that. Add a counter that you increment for each row.
---
b { font-weight: normal; }
|
|
|
|
|
Agreed. The IndexOf () is available in .NET framework 2.0.
You will have to iterate and compare to get the Row index.
Live Life King Size
Alomgir Miah
|
|
|
|
|
|
Hello there
I am some how stuck to get the attribute values of the node. rest every thing is fine . this is the code
the XML is like this (just ruff idea)
<country>
<city name="abc" location="Somewhere">
XPathDocument xdoc = new XPathDocument(reader);
XPathNavigator nav = xdoc.CreateNavigator();
XPathNodeIterator nodeItor = nav.Select("Country/City");
Now I want to get the name attribute and location attribute.
please help me out.
thanks in Advance
|
|
|
|
|
missed the XML due to tags
<Country>
<City Name="abc" location="xyz">
</Country>
|
|
|
|
|
|
Hello all
I have a Datatable, along with datarow and dataview defined:
<br />
DataTable dt = new DataTable();<br />
DataRow dr;<br />
DataView dv = new DataView();<br />
The Datatable is given these columns:
<br />
dt.Columns.Add(new DataColumn ("ID", typeof(string)));<br />
dt.Columns.Add(new DataColumn ("Antal", typeof(int)));<br />
dt.Columns.Add(new DataColumn ("belopp", typeof(string))<br />
After filling the table with data I make a view:
<br />
dv = new DataView(dt);<br />
... and then I sort it:
<br />
dv.Sort = "Antal DESC";<br />
My problem is, the sortin doesnt seem to work, when I print every row starting from the first I still get results like this:
antal<br />
2<br />
1<br />
2<br />
4<br />
4<br />
1<br />
6
Can anyone see what I'm doing wrong?
|
|
|
|
|
You must keep in mind that the DataView.Sort property will just sort the DataView and the underlying DataTable is not sorted. How are you printing thiese values
antal
2
1
2
4
4
1
6
Live Life King Size
Alomgir Miah
|
|
|
|
|
yeah, im using the view and not the actual table to display data, so I dont think thats it. Here's how I do it (just for testing I might add )
string temp = "";<br />
<br />
foreach (DataRowView dvr in dv)<br />
{<br />
temp = dvr["Antal"].ToString();<br />
}
and then I run debugger to see value of temp for every row.
|
|
|
|
|
I tried the code you have posted. It just works fine.
Live Life King Size
Alomgir Miah
|
|
|
|
|
Thanks alot mate, since it worked for you too, I took a longer look at the code where I fill the table with data. I found
dt.Rows[counter].BeginEdit();
without any
dt.Rows[counter].EndEdit();
and that seemed to be the cause of it. Thanks again!
|
|
|
|
|
I am trying to create an array of classes however when I try to assign values to the class variables I get an error: "Object reference not set to an instance of an object"
Am I declaring my array wrong?
<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
private System.Windows.Forms.Button btn_FillArray<br />
...
<br />
MyClass[] classArray = new MyClass[5];<br />
}<br />
<br />
private void btn_FillArray_Click(object sender, System.Eventargs e)<br />
{<br />
classArray[0].data = 5;<br />
}<br />
<br />
<br />
class MyClass<br />
{<br />
public MyClass()<br />
{<br />
data = 1;<br />
}<br />
<br />
public int data;<br />
}<br />
<br />
<br />
Thank you for the help - mutty
|
|
|
|
|
Hi
Each element of the array has to be "newed" up individually, after the array has been declared. The array delcaration just frees up space for the number of objects, it doesn't instantiate them.
MyClass[] classArray = new MyClass[5];
<br>
for (Int32 i = 0; i < classArray.Length; i++)
classArray[i] = new MyClass();
Hope that helped.
Sean
|
|
|
|
|
Yes, this was exactly what I was looking for. Thank you! -mutty
|
|
|
|
|
Hi
In c-sharp windows form,
create two xml files with some sample data in it.also to have a forign key in the table.
Then read them into the dataset.so your dataset should have two tables.Then create a relation betwenn those two tables in the dataset.
then place a datagrid and display it.
pls anyone teach me or just with an small example help me to do this type.
santhosh
|
|
|
|
|
You should use the class DataRelation. Search for DataRelation in MSDN, there are many samples.
Live Life King Size
Alomgir Miah
|
|
|
|
|
I am new to c#, so i am learning right now.
In a form , i had designed with a datagrid and a button.
now i have added a datset
and
coded as fllows
private void button1_Click(object sender, System.EventArgs e)
{
DataSet ds = new DataSet();
DataSet xml1 = new DataSet();
xml1.ReadXml("C:\\CDEV\\relationcosttypeandcode\\cost_code.xml");
DataTable dt1 = xml1.Tables["cost_code"].Copy();
DataSet xml2 = new DataSet();
xml2.ReadXml("C:\\CDEV\\relationcosttypeandcode\\cost_type.xml");
DataTable dt2 = xml2.Tables["cost_type"].Copy();
ds.Tables.Add(dt1);
ds.Tables.Add(dt2);
DataColumn parentCol = ds.Tables["cost_code"].Columns["cost_type"];
DataColumn childCol = ds.Tables["cost_type"].Columns["cost_type"];
DataRelation relTable1Table2;
relTable1Table2 = new DataRelation("cost_typecost_code", parentCol, childCol);
ds.Relations.Add(relTable1Table2);
dataGrid1.DataSource = ds;
}
after running this i get a error when clicking the button
"Column argument cannot be Null".
Pls any one help me to do this
santhosh
Nation of complete domination
|
|
|
|
|
Hi
I am trying to connect SQL server database 2K, which is in different machine from web server but in the same domain, from ASP.NET page but it gives error message "SQL Server does not exist or access denied" but with same connection string & same server I can connect using windows form or other application.
Does anyone has got any clue on that
Would much appreciate your help.
Thank You
Share knowledge to enhance your learning
|
|
|
|
|
What kind of authentication does your SQL server use? If you are using Windows authentication, then you probably don't have privlieges for the ASP.NET user.
Michael
CP Blog [^] Development Blog [^]
|
|
|
|
|
hi friends how can i get a collection of the names if textboxes on a panel control
please i need practical examples
|
|
|
|
|
ArrayList names = new ArrayList();
foreach(Control ctrl in myPanel.Controls)
{
if(ctrl is Textbox)
{
names.Add(ctrl.Name);
}
}
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
thanks for your reply
i think i need to know a lot about u
my approach was about 4 lines of code
but your reply has help me understand.
i'm from ghana and working as a programmer
with the softtribe
|
|
|
|
|
hi
im new to c# and this is my first attempt to create a database.. right now i only have a concept, i donno how to get started or what i need to do exactly to carry out my plan..
i've separated my groups of data in tab pages.. so now, each tab page consist of a different type of data..
1) when the user saves the tab page of data, i want the data to go into the database.. but how do i "throw" the data into my database?
2) i need to create a few sets/types of sample data eg. types of food taken and personal particulars.. where do i go to to create my sample data n how do i store these sample data in my database?
3) more importantly, im not even sure what database to create.. microsoft access or microsoft sql server or others.. which database is the best/easiest to use for my app?
4) my app is something like this >>
let's say i've these buttons : updateBtn1, viewBtn1, updateBtn2 n viewBtn2.. the user chooses what he wants to click and the page will be displayed.. if this button is to view only and it is to open a tab page about types of food taken, im supposed to retrieved only types of food taken from database and display in the tab page.. i need it to sort and only retrieve food taken and leave out personal particulars which is also kept in the same database..
if the button clicked is to open tab page to update food taken, i need to get the relevant data frm database and let user edit those data before he saves them again to database..
so my question is how do i open/display/retrieve only the relevant data for THAT tab page AND how do i save it back to database? note: the same data shd NOT be written again to database, only add NEW data in to database.. how to do this? when the user loads (whether to view or update) tab page by clicking the button, i want the page to display both old data + new data in a datagrid for example (old data means data that's already in database that is my sample data & new data means the data that was updated/added in to database..
i really appreciate it if u cld provide me with some examples of codes and how they work or some help articles or anything that u think will help..
thank you so much for trying to help! =)
|
|
|
|
|
hi i think u should read more about the database connection
and about dataset
with this you will have more idears about .net database
|
|
|
|
|