Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop Down in Grid

Status
Not open for further replies.

R7Dave

Programmer
Oct 31, 2007
181
US
Hello - I am new to ASP.NET and need help with the following

I have a grid with 3 columns and a 4th column that has a Linkbutton.

I have a dropdown that will update the 3rd column with one county. (It updates all of the counties in a state with one sales rep)

After the dropdown update, the user can click the edit linkbutton within the grid and update a single record in the 3rd column. I also want the 3rd column to have the same selection as the dropdown that is not in the grid. (this is to let the user pick certain countise for another sales rep)

How can I get the dropdown to appear in the grid after the user selects the Edit LinkButton

Thanks
Dave

 
Set the visible on the dropdown to false. use Javascript to make the dropdown visible again when the linkbutton is clicked.

David Kuhn
 
Hello

I'm not sure I understand - below is what I am trying to do - please correct me, I have the feeling I am trying to do this task with the wrong idea in mind.

- This may seem a little different than my last post, since I changed some things

STEP1: On FormLoad, display a dropdownlist displaying 50 states of USA
STEP2:
- Make a 2nd dropdownlist visible containing the available Sales Reps
- Make a datagrid listing the counties and currently assigned reps to
the state selected in STEP1

STEP3: User can select the 2nd dropdownlist for a Sales Reps which
updates a column in the datagrid like this

For Each dgi As DataGridItem In DG_County.Items
dgi.Cells(3).Text = DD_Rep.SelectedItem.Text
Next

(Why its like this...)If A state contains 45 counties and you want 40 assigned to "Fred" and 5 assigned to "Barney", you would select "Fred" with the dropdownlist

...then use the EditItemTemplate to select the last 5 for "Barney"

STEP4:

I want to loop through the grid and run a stored procedure with parameter values based on the values in the datagrid.

Steps 1 to 3 work fine -

My problems/issues/misunderstanding...

- I don't see how to commit the changes made by the EditItemTemplate after I click the EditCommandColumn.

- I only need the values of the grid changed, using a SQLDataAdapter will clear my datagrid.

- How can I let the user change a value contained in the datagrid?

I'm used to writing Windows apps so I think my thinking may be wrong.

Thanks in advance for any help.

Dave
 
When You click the Edit Command, generally it is expected that it will put that row into 'Edit Mode'. From there you would make the changes on that record, and select Update or Cancel (Which IIRC appear when you set the row into edit mode)

I would expect you to be calling the SQL on teh Update Command, not the Edit Command.

It sounds to me like you are misunderstanding or breaking the DataGrid Paradigm.

"- How can I let the user change a value contained in the datagrid?"

Code:
In your Edit Method
datagrid.EditItemIndex = e.Item.ItemIndex
//Then code here to rebind your grid

That puts the grid into edit mode on a selected row.

Cancel needs to set
datagrid.EditItemIndex = -1

And it is Update that you need to validate your input and call the stored procedure

hth

K
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top