I have a GridView with columns "Item Code, Name, Quantity, Rate". I bind the values for this columns from textboxes, not from database. It means I am adding values to GridView at runtime. Then in button click or in rowdeleting event, I want to delete selected row from GridView at runtime. Would you please provide solution for this? Thanks in advance...
Related
i have a dropdownlist in a column in a gridview. This dropdwon already had two items in it i.e Close/Open. What i require is that I bind the gridview to a dataset, all i want is for the dropdown to show the value that is in the dataset.(open or close)
I got the answer. Its a bit of an work around. You cannot directly bind the gridview dropdownlist to the dataset column. What I did instead was, I bound the Dataset column to a hiddenfield and then in Rowdatabound event i assigned the dropdown.selectedvalue to the hiddenfield.value.
Works Perfectly...Thanks everyone.
So in this photo I have a gridview,
Column 1 is DropDownList, Column 2 is TextBox and Column 3 is Read Only. for Column 1 as a TextBox, when I clicked Edit, changed the value of TextBox and then I clicked Update, the Value of Column 1 chenged. Then I replaced TextBox from column 1 to a DropDownList. I converted Column1 into a TemplateField, Edited template field of column 1 and changed it as a DropDownList. Now When I try to Edit a Row, I choose another value from DropDownList and it doesn't change.
NOTE: I haven't don this programmatically. .aspx.cs file is empty. I have done this via GridView Tasks.
UPDATE:
I have managed to fix the problem.
On EditTemplateField, on DropDownList I clicked Edit Data Bindings
After that on Selected Value I bounded it to the column I want.
When I use sorting (header column) in datagridview, all rows that were previously checked became unchecked. Why is this happening?
Is there a way to prevent unchecking checkboxes on sorting with header column?
Because you rebind your datagridview without selected datas so you erase , you must persist your selected datas
I need to give color of gridview on some condition in datatable. The column is NOT added in gridview but is present in datatable. It checks that if country is USA the color the row as green.
The setting can be done from gridview row databound but not sure how to access the datatable column in rowdatabound.
Thanks!
You cant access Datatable once u assigned it to grid as Datasource for that column as it is not added to grid.
You can add same column in gridview wth visible=false so that u can access it in rowdatabound event of grid and accordingly change color.
Hope this help.
Suppose I have a e-shop web app. I have a product categories table in my database that populates a gridview using sqldatasource.
I want to be able to click on the select hyperlink on a row and use that event to populate ANOTHER gridview based on the ID of the product category that is clicked. E.g say the 'CDs' row is clicked, another gridview shows all the different CDs.
As a result, I need the select(sql) statement for the second table to be dynamic based on what the user clicks.
Has anyone done anything like this before?
Any help would be greatly appreciated,
Mark
It should be very easy. The key is to use SelectedValue of first Gridview to be used as a parameter to the query to populate second gridview.
Here is a sample: Master/Detail GridView
The sample show GV and DetailsView but in your case you replace DV with another GV.