|
Rank: Newbie Groups: Member
Joined: 3/25/2013 Posts: 6
|
Hi,
i am trying to use the functionalities from Custom Column Advanced and Advanced 2.
I want when i am changing the value of the dropdown , then based on the value of dropdown a value to be retrieved from database and then this value to be fill a cell of grid.
Add the end i want all these values to be added to database using a button and "AddedItems" as the sample.
But when i am using this functionality (making use of ItemCommand) then i am receiving for AddedItems.lengh = 0.
If i remove ItemCommand , Added Items is working perfect.
Can you help me??
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
That's normal. AddedItems ONLY has values when the page posts back for the first time. Because ItemCommand causes a post back, so during that postback AddedItems has values. However it will be empty the next time the page posts back. This is necessary so that code that relies on AddedItems to update database not to be called multiple times thus adding duplicate records into the database. If you do not want to miss any AddedItems, you may want to always check AddedItems in Page_Load.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/25/2013 Posts: 6
|
Thanks for your answer, i would like also to ask. Dropdownlist is in the beginning of the row and then, there are some else fields that must be filled by the user. how can then retrieve the total of these values in order to fill the database??
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
I am not exactly sure what you meant by "multiple value". When you use custom column, you provide the editing UI and the Grid holds the value for you. So whatever values you have, you must return it to the Grid. For example, if you use multiple cells, then you can return a separate value to each cell; Or if you only use one cell, then can somehow merge multiple values into a single value and store that single value in that cell. Whatever value you pass to the Grid, the Grid holds it and pass it to your server side code. You can then modify your server side code accordingly fill the database.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/25/2013 Posts: 6
|
i have a row with the following cells: 1. dropdownlist with the product 2. cell with the productid (that is retrieved from ItemCommand , as in the example) 3. the cost of the product (this cell if filled when dropdown is changed 4. the quantity
According to your answer, when i select the product (from dropdownlist) the itemcommand will be fired and also the postback event and due to this, the addeditems event of the grid.
Because the itemcommand and postback event will be fired, i can retrieve only the dropdown list with addeditems. how can i retrieve the other cells and the other rows? is there another event that i can retrieve these values??
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
I am not sure if I understand your question. AddedItems returns the full row. So it will be something like this:
Grid1.AddedItems[itemIndex].Cells[columnIndex].Value
Or
Grid1.ChangedItems[itemIndex].Cells[columnIndex].Value
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/25/2013 Posts: 6
|
I'll try it!! thank you for your response!!
|
|