Forms Data Controls :: Get Info On Gridview When Updating Dropdown On Row?
Feb 4, 2010
I have a gridview that has a dropdown on a template on the row. The user is wanting to change the value and update the record automatically. I know that when the value changes, I need to have the OnChange to trigger. I am not sure how to get the row so I can get the record ID so I can create a SQL statement to update this field.
Should I be using something other than the gridview?
When i Updating my gridview and i modify the value of dropdown the update is all ok, but if i not modify the dropdown and leave the selected value after the update i see another value, the first of listitem of my dropdown.
This is my code:
Sub GrdUpdate(ByVal sendere As Object, ByVal e As GridViewUpdateEventArgs) Dim ID_ricette, NomeRicetta As String Dim NomePortata As DropDownList Dim NomePortataSel As String If Not e.NewValues(0) Is Nothing Then ID_ricette = e.NewValues(0).ToString NomeRicetta = e.NewValues(1).ToString..........
'm using a textbox to get the first 5 letters of the name.
An sqldatasource then finds the people who have names > than the five letters and picks up their ID numbers as well as their names.
After that I use a second sqldatasource to get one individual from that dropdownlist's persons name and id number and then using a detailsview I display that person.
Well both sqldatasouces work fine but it just does not pass the ID number when I debug it.
I am having issues with this.. If you could help that would be great. I am not a coding expert, but I am trying to learn as I go. I am having problems taking the value from my dropdown list (tabl1) and updating table2 with the selected value.I have my grid / form showing my table2 data, I have 1 of the dropdown fields being populated from table1, when I change the specified dropdown box and click update, the data in table2 stays the same.
I'm trying to make a order form where once the user selects an item from the drop down list, the label will automatically be populated with the user's selection.suppose user select item from drop down then label populate rate for that itemve me a sample example..
I have a gridview on which there is a colume of image button for user to select a particular row. When a row is selected, a modal pop up appears for user to edit data and finally uers hit update button (within modal pop up). I expect to update the selected gridview row with info on modal pop up. My question is how do I get the row number within the Update_Click event.
I've been hunting for a solution to grab the radiobuttonlist when they answer that particular question. It varies for the number of questions, but only one displays at a time, but there could be a radiobuttolist or checkboxlist based on the question type. I was figuring I could do this easy in the row command of the gridview, but that hasn't worked out so well since I can't get the datarow for some reason.
i have a dropdown with month names if the user has data for the month tht is selected then gridview displays the rows with day nos as per the month but if the gridview has no data for the same the dropdown or gridview via some event should call a insert procedure to insert data into the table for tht month with daynos ad rebind the gridview witht the rows just created
I have a gridview where i have two fields. one is product and second is sub category.
I need to do 2 things.
1. I need to populate the two combos from the database. But depending what is selected in dropdown 1 this will determine what needs to be populated in drop down 2?
I have two gridviews, where the first is databound to a sql table (but does not display the primary key info), and want to filter the data displayed on the second gridview by using the primary key info from the first gridview table, indicated by the selected row in the first gridview - how I could achieve this? its kind of like using the gridviews as a menu and sub menu display!
almost typical master-detail scenario except the 'detail' data I want to display below the gridview will be coming from both the table that is bound to the gridview (master) and a related table.
simplified example: tableMain with field1, field2, field3 bound to master gridview. I need to select a row from the master gridview and have a form display below with field4 and field5 from tableMain, as well as all fields of tableDetail where field1 of tableMain equals field1 of tableDetail.
Is this what a 'formview' control is for? or do I just arrange my own controls to accommodate the data? Would a formview work considering my source will be partially from both the main table and the detail table? This is one of the scenarios were I know I could come up with something using none of the databound controls (except the master gridview), but I want to use the controls provided when it makes sense to do so, and utilize their benefits etc...
I have a parent gridview which has a child gridview in the itemsTemplate. Both are binded to different SqlDataSources. I can successfully update and delete rows in the child gridview. After updating in the child gridview, some related data in the parent gridview are not updated automatically. So i have placed ParentGridview.Databind() in the rowupdated event of child gridview. But it doesnt look working.
I generate dynamic grids based on a count value returned from some DB tables. the code for it goes like this : I give and Id to each grid that is generated.
if (myDataList1.Count >= 1) { for (int i = 0; i < myDataList1.Count; i++) { //retrieving the exact i count from pageload ViewState.Add("newCount", i); //creating the dynamic grid with its corresponding gridview properties. grvDynamic = new GridView(); grvDynamic.ID = "GridView" + (i+3); grvDynamic.AutoGenerateColumns = false; grvDynamic.RowCreated += GridViewRowCreated; grvDynamic.RowDataBound += grvDynamic_RowDataBound; //adding bound field columns to retrieve data from stored proc BoundField metric = new BoundField(); metric.HeaderText = "Goal "; metric.DataField = "metric"; grvDynamic.Columns.Add(metric); BoundField mtd = new BoundField(); mtd.HeaderText = "MTD"; mtd.DataField = "value_MTD"; grvDynamic.Columns.Add(mtd); BoundField goal = new BoundField(); goal.HeaderText = "Tier Level Achieved"; goal.DataField = "value_goal"; goal.HeaderStyle.Width = Unit.Percentage(10); grvDynamic.Columns.Add(goal); BoundField you1 = new BoundField(); you1.HeaderText = "Month End"; you1.DataField = "firstLevel_you"; grvDynamic.Columns.Add(you1); BoundField you2 = new BoundField(); you2.HeaderText = "Month End"; you2.DataField = "secondLevel_you"; grvDynamic.Columns.Add(you2); ButtonField singleClick = new ButtonField(); singleClick.CommandName = "clickHyperlink"; singleClick.Visible = false; grvDynamic.Columns.Add(singleClick); BoundField metricId = new BoundField(); metricId.HeaderText = "Metric Id"; metricId.DataField = "metricID"; metricId.Visible = true; grvDynamic.Columns.Add(metricId); //binding the gridview to data. grvDynamic.DataSource = data; grvDynamic.DataBind(); grvDynamic.Columns[5].Visible = false; } }
protected void grvDynamic_RowDataBound(object sender, GridViewRowEventArgs e) { //this basically gets the metric Id's of rows with the ishyperlink flag set to 'Y'. I need to make these particular cells clickable var isClickable = (from md in myDataList3 where md.IsHyperLinkFlag == 'Y' &&
md.value_MTD != null select md.metricID).ToList(); if (e.Row.RowType == DataControlRowType.DataRow) { // Get reference to button field in the gridview. LinkButton _singleClickButton = (LinkButton)e.Row.Cells[5].Controls[0];
This code works perfectly fine , depending on the ishyperlink flag in the database...specific cells in the grid are made clickable and then redirected to page2.aspx My Issue: I need to capture which specific cell in which specific grid the user has clicked. store some information in sessions based on the cell clicked and use that information in page2.aspx.
I am using LINQ to SQL and on my DetailsView it updates fine but with my gridview it is not. Both I used template fields so I am not sure what the issue is?
[Code]....
[Code]....
[Code]....
I have been doing a lot of reading and searching and I cannot figure out why this is not working for me.
It does not give me any errors and seems to work but the grid view cell do not take this session. When I'm clicking on the edit hyperlink this event is triggered.
Having a bit of difficulty working this gridview update problem out - I have managed to get edit/update function working but instead of only updating the current gridview row it is updating the whole table I believe this is due to a missing where statement on my Update statement - to single out the row index of my grid row.When I configure my sql datasource I am using custom statements Here is my update statement
I have a gridview that holds 4 columns. in the fourth column there is a DropDownlist that holds three items.
I want my users to select one of the values and when they do the auto post back (which is set to true) should execute a method that updates the database selected row. But do i use the selectedindexchanged of the DDL or the Gridview? My head is totally thrashed so i imagine its really simple and im just over thinking it.
i wanted to refresh the gridview once user enters values and clicks update button. But its not updating. If i change my selection to pop up gridview, then it is showing the updated values. I dont know where i am doing wrong. can any one suggest changes in my code?
I'm using a GridView to retrieve data from a stored procedure using a SQLDataSource (db is SQL Server 2008). When I compile my application and go to my website, all the data is loaded and shown fine. If I was to add a new entry to the table however (a seperate page on my website has a Wizard control to facilitate this) and then return to the page with the GridView, the new entry doesn't show up.
Looking from SQL Server, the data has been added, but the GridView isn't updating to show it. If I were to recompile the project with F6 and refresh the page, the new data will show up. I tried calling DataBind() on the GridView in the Page Load event, however the issue still remains.
where I have gone wrong? changing from VS2003 DataGrid to VS2010 GridView; still on SQL Server 2000 so the wizards for autogenerating the code are not compatible.
Delete works, RowUpdating does not. I get an ArgumentOutOfRangeException on "rowToUpdate("QuoteDQty") = Me.dgQuoteList.Rows(e.NewValues.Item(1).ToString)" Private Sub dgQuoteList_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles dgQuoteList.RowUpdating [code]...