| | |
Problem with DataGrid
Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
I have 2 datagrid, 1 with details of Category and the other with the products user selected from the other datagrid, what Im saying is I have a select command on my 1st datagrid so when I select something from my 1st datagrid it should be added to the 2nd datagrid and that is workin but the problem is everytime I select somethin from the 1st datagrid adding to the 2nd datagrid it overwrites the existing record on the 2nd datagrid instead of adding on top of... can anyone help me please here the code to add what is from the 1st grid to the second one
Thanx in advance
C# Syntax (Toggle Plain Text)
imgItems.ImageUrl = "Pictures/" + dgItems.SelectedItem.Cells[2].Text; string strDetails = "sdp_ViewProducts"; //CommandType.StoredProcedure; DataSet dsDetails = new DataSet(); SqlDataAdapter daDetails = new SqlDataAdapter(strDetails, conn); daDetails.SelectCommand.CommandText = "Select ProductID, ProductName, UnitPrice, UnitsInStock, UnitsOnOrder from dbo.Products where ProductID = " + dgItems.SelectedItem.Cells[1].Text; daDetails.Fill(dsDetails, "Products"); dgDetails.DataSource = dsDetails; dgDetails.DataMember = "Products"; dgDetails.DataKeyField = "ProductID"; dgDetails.DataBind(); dgDetails.Visible = true;
Thanx in advance
Some people get so rich they lose all respect for humanity. That's how rich I want to be.
Hi...
The code you are following does overwrites the Grid.
What you can do is
- Copy the data getting from the dsDetails.Table[0] into the DataTable
- Copy that Datatable into the session
- and then merge that datatable coming from dsDetails.Table[0] with the session Datatable everytime
- then Bind the Datatable from the session into dgDetails
The code you are following does overwrites the Grid.
What you can do is
- Copy the data getting from the dsDetails.Table[0] into the DataTable
- Copy that Datatable into the session
- and then merge that datatable coming from dsDetails.Table[0] with the session Datatable everytime
- then Bind the Datatable from the session into dgDetails
Njoy koding... >>>
•
•
Join Date: Nov 2008
Posts: 63
Reputation:
Solved Threads: 10
You might want to put the datasource of datagridview2 into a viewstate and read it back after Page.IsPostBack.
That aint hard to manage....
After the ispostback is checked you can add records to the dtMemory datatable for each field the user has selected.....
That aint hard to manage....
ASP.NET Syntax (Toggle Plain Text)
' general declarations dtMemory as datatable=new datatable("YouNameIt") ' In the PageLoad_Event() : if page.ispostback then dtMemory = ctype(Viewstate("TEST"), datatable) else dtMemory = tblAdapter.Fill(blablabla) ViewState("TEST") = dtMemory end if DataGridView2.datasource = dtMemory DataGridView2.datakeynames = new string() {"Your_ID_Field_Name} DataGridView2.databind
After the ispostback is checked you can add records to the dtMemory datatable for each field the user has selected.....
![]() |
Similar Threads
- select row in datagrid....need help (VB.NET)
- Problem on Datagrid (ASP.NET)
- Datagrid font display problem. (Visual Basic 4 / 5 / 6)
- Javascript Problem.... (JavaScript / DHTML / AJAX)
- How to Show Database In DataGrid Using DAO (Visual Basic 4 / 5 / 6)
- Paging in dataGrid (ASP.NET)
- Working on Datagrid with Listboxes !! (ASP.NET)
- Datagrid is not working that well in edit mode (ASP.NET)
- datagrid not showing images in Mozilla. (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: Disable toolstripbutton in c# windows application
- Next Thread: Problem With textboxes Please help
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer c# cac checkbox class commonfunctions compatible content contenttype countryselector courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv formatdecimal formview gridview gudi iframe iis javascript listbox menu microsoft mouse mssql multistepregistration nameisnotdeclared news opera panelmasterpagebuttoncontrols problem redirect registration relationaldatabases reportemail schoolproject security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql sql-server sqlserver2005 ssl textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visual-studio visualstudio web webapplications webarchitecture webdevelopemnt webdevelopment webprogramming webservice youareanotmemberofthedebuggerusers





