Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem in displaying data.

Problem in displaying data.

Scheduled Pinned Locked Moved ASP.NET
helpcsharpdatabaselinqdesign
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    manikumar_gutti
    wrote on last edited by
    #1

    Hi, I am mani. I have a problem in display the data in datagrid. What i did is I am creating a form and in this form i created a 6 textboxes and one search button. whenever the user enter a text in textbox i retrieve the data from the database and displayed in the datagrid. The problem is when the user again enter the text in text box the datagrid is filled with new data and last data will be lost. But i want that newly searching data should be displayed in datagrid including the last searching data. This is my problem i sent last time to this portal. i got some answers. But using the DataTable i didnt get the answer. I write my code here. please tell me what is the wrong i did it in this. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; public partial class AdvanceSearch : System.Web.UI.Page { SqlConnection con; SqlCommand cmd; SqlDataAdapter adptr; DataTable dt; DataView dv; protected void Page_Load(object sender, EventArgs e) { if (Session["mani"] == null) { dt = new DataTable(); Session["mani"] = dt; } else { dt = (DataTable)Session["mani"]; } dv = new DataView(dt); SearchResultGrid.DataSource = dv; SearchResultGrid.DataBind(); } protected void ButtonSearch_Click(object sender, EventArgs e) { con = new SqlConnection("Data Source=MVB;Initial Catalog=Communication; Integrated Security=True"); string select_query = "SELECT *FROM CommunicationDetails WHERE CommunicationId=@comid OR IssueType=@issue OR RegionName=@regname OR ApplicationName=@appname OR Descript=@Desc OR CommunicationDate=@comdate"; cmd = new SqlCommand(select_query, con); cmd.Parameters.Add("@comid", TextBoxCommunicationID.Text); cmd.Parameters.Add("@issue", TextIssueType.Text); cmd.Parameters.Add("@regname", TextBoxRegionName.Text); cmd.Parameters.Add("@appname", TextBoxApplicationName.Text); cmd.Parameters.Add("@Desc", TextBoxDescription.Text); cmd.Parameters.Add("@comdate", TextBoxDate.Text); try { con.Open(); adptr = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); adptr.Fill(ds); dt

    W 1 Reply Last reply
    0
    • M manikumar_gutti

      Hi, I am mani. I have a problem in display the data in datagrid. What i did is I am creating a form and in this form i created a 6 textboxes and one search button. whenever the user enter a text in textbox i retrieve the data from the database and displayed in the datagrid. The problem is when the user again enter the text in text box the datagrid is filled with new data and last data will be lost. But i want that newly searching data should be displayed in datagrid including the last searching data. This is my problem i sent last time to this portal. i got some answers. But using the DataTable i didnt get the answer. I write my code here. please tell me what is the wrong i did it in this. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; public partial class AdvanceSearch : System.Web.UI.Page { SqlConnection con; SqlCommand cmd; SqlDataAdapter adptr; DataTable dt; DataView dv; protected void Page_Load(object sender, EventArgs e) { if (Session["mani"] == null) { dt = new DataTable(); Session["mani"] = dt; } else { dt = (DataTable)Session["mani"]; } dv = new DataView(dt); SearchResultGrid.DataSource = dv; SearchResultGrid.DataBind(); } protected void ButtonSearch_Click(object sender, EventArgs e) { con = new SqlConnection("Data Source=MVB;Initial Catalog=Communication; Integrated Security=True"); string select_query = "SELECT *FROM CommunicationDetails WHERE CommunicationId=@comid OR IssueType=@issue OR RegionName=@regname OR ApplicationName=@appname OR Descript=@Desc OR CommunicationDate=@comdate"; cmd = new SqlCommand(select_query, con); cmd.Parameters.Add("@comid", TextBoxCommunicationID.Text); cmd.Parameters.Add("@issue", TextIssueType.Text); cmd.Parameters.Add("@regname", TextBoxRegionName.Text); cmd.Parameters.Add("@appname", TextBoxApplicationName.Text); cmd.Parameters.Add("@Desc", TextBoxDescription.Text); cmd.Parameters.Add("@comdate", TextBoxDate.Text); try { con.Open(); adptr = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); adptr.Fill(ds); dt

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      One possibility is that when you make a new query: - save the last results in a datatable 1 (the currently binded datatable) - execute a new query - from the query save the results to datatable 2 - merge datatable 1 and 2 to datatable 3 - bind the datatable 3 to the grid You can do this with two datatables also if you want. For information about Merge, see http://msdn.microsoft.com/en-us/library/fk68ew7b.aspx[^]

      The need to optimize rises from a bad design.My articles[^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups