473,748 Members | 2,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

databind a gridview to a dictionary<stri ng, string> only shows 1 row?

I don't know if this is even working or not but here is the problem. I have
a gridview that I databound to a dictionary<stri ng, stringcollectio n:

Contract StockContract = new Contract();
StockContract.D ictionary = ContractDiction ary<string, string>();
GridView1.DataS ource=StockCont ract.Dictionary ;

So far so good. Now I assign something to the Dictionary collection through
some textboxes and a button:

protected void AddDefinitionBu tton_Click(obje ct Sender, EventArgs e) {
StockContract.D ictionary.Add(W ordTextBox.Text , DefinitionTextB ox.Text);
GridView.DataBi nd();
}

The outcome is this: When I type into the 2 textboxes say, "test" for
WordTextBox and "first test" for DefinitionTextB ox and hit the add button,
everything turns out fine. Now when I type in "clock" for the word and "you
tell time with it" for the definition and press the add button, the GridView
refreshes but with only 1 row instead of 2. What could be the problem? Here
is the code for the method I use for this. I'm not even sure if all of the
definitions are getting added to the dictionary collection the way they are
supposed to. Is there a way to find out if they are? Anyways, here is the
code for the method:

private void AddDefinition() {

///Todo: Add validation for adding duplicate words, empty values

string value = "";

StockContract.D ictionary = new ContractDiction ary<string, string>();

//If the word already exists, do nothing except show a message saying the
word already exists.

if(StockContrac t.Dictionary.Tr yGetValue(WordT extBox.Text, out value)) {

DefinitionList. Caption = "That word already exists, try again!";

}

else {

StockContract.D ictionary.Add(W ordTextBox.Text , DefinitionTextB ox.Text);

}

DefinitionList. DataSource = StockContract.D ictionary;

DefinitionList. DataBind();

WordTextBox.Tex t = String.Empty;

DefinitionTextB ox.Text = String.Empty;

}


Jun 27 '08 #1
2 3136
On 25 Apr, 20:45, "Andy B" <a_bo...@sbcglo bal.netwrote:
I don't know if this is even working or not but here is the problem. I have
a gridview that I databound to a dictionary<stri ng, stringcollectio n:

Contract StockContract = new Contract();
StockContract.D ictionary = ContractDiction ary<string, string>();
GridView1.DataS ource=StockCont ract.Dictionary ;

So far so good. Now I assign something to the Dictionary collection through
some textboxes and a button:

protected void AddDefinitionBu tton_Click(obje ct Sender, EventArgs e) {
StockContract.D ictionary.Add(W ordTextBox.Text , DefinitionTextB ox.Text);
GridView.DataBi nd();

}

The outcome is this: When I type into the 2 textboxes say, "test" for
WordTextBox and "first test" for DefinitionTextB ox and hit the add button,
everything turns out fine. Now when I type in "clock" for the word and "you
tell time with it" for the definition and press the add button, the GridView
refreshes but with only 1 row instead of 2. What could be the problem? Here
is the code for the method I use for this. I'm not even sure if all of the
definitions are getting added to the dictionary collection the way they are
supposed to. Is there a way to find out if they are? Anyways, here is the
code for the method:

private void AddDefinition() {

///Todo: Add validation for adding duplicate words, empty values

string value = "";

StockContract.D ictionary = new ContractDiction ary<string, string>();

//If the word already exists, do nothing except show a message saying the
word already exists.

if(StockContrac t.Dictionary.Tr yGetValue(WordT extBox.Text, out value)) {

DefinitionList. Caption = "That word already exists, try again!";

}

else {

StockContract.D ictionary.Add(W ordTextBox.Text , DefinitionTextB ox.Text);

}

DefinitionList. DataSource = StockContract.D ictionary;

DefinitionList. DataBind();

WordTextBox.Tex t = String.Empty;

DefinitionTextB ox.Text = String.Empty;

}- Hide quoted text -

- Show quoted text -
Why are you using a dictionary list instead of a DataTable?
Jun 27 '08 #2
How easy is it to serialize a DataTable contents to an xml file as part of a
larger object to be serialized?

I have the object Contract that has many, many different parts to it. One of
those parts is a dictionary (glossary) and a contract sections (the
different parts that make up the text of the contract object). This whole
contract object must be serialized, digitally signed eventually and then
inserted in a database as an xml field. Can you do all of this by using
dataTables as object properties? The other condition to all of this is that
it can be taken out of the database as an xml object, deserialized from the
xml object back into the contract object and then reused again.
"Stan" <go****@philpha ll.me.ukwrote in message
news:ac******** *************** ***********@x41 g2000hsb.google groups.com...
On 25 Apr, 20:45, "Andy B" <a_bo...@sbcglo bal.netwrote:
>I don't know if this is even working or not but here is the problem. I
have
a gridview that I databound to a dictionary<stri ng, stringcollectio n:

Contract StockContract = new Contract();
StockContract. Dictionary = ContractDiction ary<string, string>();
GridView1.Data Source=StockCon tract.Dictionar y;

So far so good. Now I assign something to the Dictionary collection
through
some textboxes and a button:

protected void AddDefinitionBu tton_Click(obje ct Sender, EventArgs e) {
StockContract. Dictionary.Add( WordTextBox.Tex t, DefinitionTextB ox.Text);
GridView.DataB ind();

}

The outcome is this: When I type into the 2 textboxes say, "test" for
WordTextBox and "first test" for DefinitionTextB ox and hit the add
button,
everything turns out fine. Now when I type in "clock" for the word and
"you
tell time with it" for the definition and press the add button, the
GridView
refreshes but with only 1 row instead of 2. What could be the problem?
Here
is the code for the method I use for this. I'm not even sure if all of
the
definitions are getting added to the dictionary collection the way they
are
supposed to. Is there a way to find out if they are? Anyways, here is the
code for the method:

private void AddDefinition() {

///Todo: Add validation for adding duplicate words, empty values

string value = "";

StockContract. Dictionary = new ContractDiction ary<string, string>();

//If the word already exists, do nothing except show a message saying the
word already exists.

if(StockContra ct.Dictionary.T ryGetValue(Word TextBox.Text, out value)) {

DefinitionList .Caption = "That word already exists, try again!";

}

else {

StockContract. Dictionary.Add( WordTextBox.Tex t, DefinitionTextB ox.Text);

}

DefinitionList .DataSource = StockContract.D ictionary;

DefinitionList .DataBind();

WordTextBox.Te xt = String.Empty;

DefinitionText Box.Text = String.Empty;

}- Hide quoted text -

- Show quoted text -

Why are you using a dictionary list instead of a DataTable?

Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
16982
by: Joanna Carter \(TeamB\) | last post by:
I would like to copy the contents of a Dictionary<string, object> to another Dictionary<string, object>. Do I have to iterate the source use something like foreach or is there an easier way ? Joanna -- Joanna Carter Consultant Software Engineer
7
8736
by: Wilson | last post by:
Hi, How do get the Dictioanry object from FiedlInfo ? my code : fieldInfo = this.GetType().GetField("dictioanry1"); ??Dictionary<string, string> dicTemp1 = (Dictionary<string, string>)fieldInfo; Thanks Wilson
6
46187
by: buzzweetman | last post by:
Many times I have a Dictionary<string, SomeTypeand need to get the list of keys out of it as a List<string>, to pass to a another method that expects a List<string>. I often do the following: <BEGIN CODE> List<stringkeyNameList = new List<string>(); foreach (string keyName in this.myDictionary.Keys)
4
23965
by: Mark Rae | last post by:
Hi, Is it possible to create a case-insensitive List<stringcollection? E.g. List<stringMyList = new List<string>; MyList.Add("MyString"); So that:
4
12223
by: Maikeru | last post by:
I am trying to create a map that contains a string as the key and a list of strings as the value. Essentially it will be a dictionary where the key is an English word and the list will contain all Latin equivalents. My program reads from a file containing Latin words and their English equivalents. I am using the operator from map so that I can add to the list<string> should the Key already exist in my map. I am not sure of the syntax that I need...
2
5895
by: Assimalyst | last post by:
Hi I have a Dictionary<string, List<string>>, which i have successfully filled. My problem is I need to create a filter expression using all possible permutations of its contents. i.e. the dictionary essentially creates the following array: Key Value
2
2932
by: Andy B | last post by:
Is it possible to serialize to xml a dictionary<string, stringobject in ..net 3.5?
6
7271
by: Paul.N.Phillips | last post by:
I am using a static dictionary to objects (like cache) but woundered if it is better to use cache. Which one would should I use?
2
12856
by: jandeerit | last post by:
hi... can anyone help to show me how to store the array in a dictionary object as shown below? FROM: Array : "PARAMETERS" : "ParamName-1" : "ParamValue-1" : "ParamName-2" : "ParamValue-2"
0
8995
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9561
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9332
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8252
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.