ADO/ADO.NET - Send Multiple rows sent to another page gridview

Asked By Hozefa Unwala
09-Feb-10 11:02 AM
I have one gridview with checkbox  in one page.In this page if i have been select checkbox only that rows are stored in querstring.Now i want to send selected rows send to another page.Whatever the rows i have been selected on previous page only that rows to be display in the new page and it must be inside the gridview.
Thank you
  Huggy Bear replied to Hozefa Unwala
09-Feb-10 11:42 PM
There are two ways to achieve

1. Send the Unique indexes of the selected gridview rows as comma seperated through the query string. But make sure that in the new page you split the string using Split(',') function and retrieve the data from database based on the indexes.

2. Else make use of Session object. Instead of passing the rows through query string stored them in a session object and access the same session object in the new page.
  Sreekumar P replied to Hozefa Unwala
10-Feb-10 12:51 AM
hi,

the best and simple method for is to pass the ids or row index which u are checked and get data according to the ids from the next page.

u cant access a control from previous page until unless u have done a Server.Transfer replacing Response.Redirect()

Hi  Hi

15-Feb-10 05:51 AM

Hi,

If you are using DataTable as DataSource you can Cache the DataTable in new Object Add a new temp Column
called TempSelected(DataType DBType.Bit) Set Default value to 0 .

On grid cell change event - (Check if ActiveCell key is Check box) If Yes
Get the Value of the Active cell and Update Datable ( if checked set TempSelected Value to  1)

Set the new Filtered DataView as DataSouce to new Grid in the next Page.

DataView dv = new DataView(DataTable.DefaultView);
(dv.RowFilter = "TempSelected = 1")

DataGrid.DataSource = dv;

This is one way you can go with.



Hope this helps!
Regards
gmdarsh

Create New Account
help
Frequently asked Interview Questions in ADO.Net hi friends Any one send frequently asked Important questions in C# .Net, ADO .Net, Asp .Net and Sql Server. . . . . . . . tx in Advance. . . . . . Hi, Find this. . (B)What is an using cache object of ASP.NET? (B) How can you cache different version of same page using ASP.NET cache object? (A) How will implement Page Fragment Caching? (B) Can you compare ASP.NET sessions with classic ASP? (B) Which are of using Query Strings? (I) What is Absolute and Sliding expiration? (I) What is cross page posting? 93 (I) How do we access viewstate value of this page in the next page ? (I) Can we post and access view state in another application
OleDb.OleDbException Imports System.Web.UI.HtmlControls.HtmlInputFile Partial Class parameter_Default Inherits System.Web.UI.Page Private ds, value As DataSet Private QueryService As New QueryService.QueryService Private public_service As New DataSet Dim ErrExc As New ErrorHandler Dim ds1, ds4 As New DataSet Dim objDatatable As DataTable Dim exe As System.Data.OleDb.OleDbCommand Dim dr As DataRow Dim oracleBulkCopy As String ds = New DataSet() da.Fill(ds) Dim ds1 As New DataSet() Dim dt As New DataTable("badge") Dim cl1 As New DataColumn("PlazaNo") cl1.DataType = GetType(String) Dim cl2 As New DataColumn("BadgeNo") cl1.DataType = GetType(String) Dim cl3 As New DataColumn("GroupLevel") cl1.DataType = GetType(String) Dim cl4 As New DataColumn("BadgeName") cl1 DataType = GetType(String) Dim cl5 As New DataColumn("Password") cl1.DataType = GetType(String) Dim cl6 As New DataColumn("MFGNo") cl1.DataType = GetType(String) dt.Columns.Add
an application named Store Procedure in .net to use the above sprocs. Stored Procedure.aspx page code <% @ Page Language = "C#" AutoEventWireup = "true" CodeFile = "Default.aspx.cs" Inherits = "_Default" %> <! DOCTYPE html PUBLIC "- / / W3C / / DTD runat = "server" Text = "Submit Record" OnClick = "Button1_Click" / > < / div > < / form > < / body > < / html > Stored Procedure.aspx.cs page code using System; using System.Data; using System.Configuration; using System.Web; using System.Web System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class _Default : System.Web.UI. Page { DataSet ds = new DataSet (); SqlConnection con; / / Here we declare the parameter which we have to this: Hi. . FIrst Create A stored procedure . . . . . . . CREATE PROCEDURE dbo.StoredProcedure1 / * ( @parameter1 int = 5, @parameter2 datatype OUTPUT ) * / AS / * SET NOCOUNT ON * / RETURN Then call this code using C# ConnectionString. . . <connectionStrings> <add namespace DBtutorials { public class StoredProcedures { public StoredProcedures() { } / / / <summary> / / / Gets all columns from Table1 / / / < / summary> / / / <returns> DataTable of all columns in Table1< / returns> public static DataTable GetAllData() { DataTable allData = new DataTable(); SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ToString()); try { SqlCommand cmd = new
call it from within a C# application Calling Stored Procedure A very nice aspect of ADO.NET is that it allows the developer to call a stored procedure in almost the exact Create a new C# Windows Application project. 2. From the Toolbox, drag and drop a DataGrid onto the Form. Resize it as necessary. 3. Double-click on the Form to generate affected by the statement. Untitled document Procedure ALTER PROCEDURE dbo.StoredProcedure2 / * ( @parameter1 int = 5, @parameter2 datatype OUTPUT ) * / AS / * SET NOCOUNT ON * / select * from emp ; RETURN ► Now add a Method in class file: public static DataTable getdata() { string conn = ConfigurationManager .ConnectionStrings[ "ConnectionString" ].ConnectionString; SqlConnection con = new SqlConnection (conn); con.Open(); SqlCommand comm = new SqlCommand ( "StoredProcedure2" , con); comm.CommandType = CommandType .StoredProcedure; SqlDataAdapter da = new SqlDataAdapter (comm); DataTable dt = new DataTable (); da.Fill(dt); return dt; } ► Use a Method in aspx.cs file: protected void Page_Load System.Data.SqlClient; using System.Web.Configuration; namespace DBtutorials { public class StoredProcedures { public StoredProcedures() { } / / <returns> DataTable of all columns in Table1< / returns> public static DataTable GetAllData() { DataTable allData = new DataTable(); SqlConnection
to use this query in VB.NET2003, I want to show the student detail in datagrid view. I have written a ADO.NET code as follows à 1) cnn = New OleDbConnection cnn.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4 cnn) da = New OleDbDataAdapter da.SelectCommand = cmdSelect ds = New DataSet da.Fill(ds) dt = New DataTable dt = ds.Tables(0) dv = New DataView dv.Table = ds.Tables(0) curMode = AccessMode.Showmode cnn) da = New OleDbDataAdapter da.SelectCommand = cmdSelect ds = New DataSet da.Fill(ds) dt = New DataTable dt = ds.Tables(0) dv = New DataView dv.Table = ds.Tables(0) curMode = AccessMode.Showmode ID from T1 where Id = " + txtId.Text.ToInt32()+ " Order by ID ", cnn ) depending on the datatype of the Id column. . It it is varchar2 type just use txtId.Text instead of txtId.Text.ToInt32() which is for number type I want simple search page which display the data in datagrid view acording to userId If user enter id as 1 then automatically it display the