Write Code for DataSet,Datareader,and by deleting the button
gridview should be empty?



Write Code for DataSet,Datareader,and by deleting the button gridview should be empty?..

Answer / Ritesh Kumar Siddharth

Here's a simple example of using DataSet and DataReader with ADO.NET in C#:nnFirst, create a function to fill a DataSet:n```csharpnpublic static DataSet FillDataSet(string connectionString, string query)n{n SqlConnection connection = new SqlConnection(connectionString);n SqlCommand command = new SqlCommand(query, connection);n DataSet dataSet = new DataSet();n SqlDataAdapter adapter = new SqlDataAdapter(command);n adapter.Fill(dataSet);n return dataSet;n}n```nNext, create a function to fill a DataReader:n```csharpnpublic static void FillDataReader(string connectionString, string query, Action<SqlDataReader> action)n{n SqlConnection connection = new SqlConnection(connectionString);n SqlCommand command = new SqlCommand(query, connection);n connection.Open();n SqlDataReader reader = command.ExecuteReader();n action(reader);n reader.Close();n}n```nFinally, to empty a GridView after deleting a row, simply bind an empty DataTable to the GridView's DataSource property:n```csharpngridView1.DataSource = null;ngridView1.DataSource = new DataTable();ngridView1.DataBind();n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Dot Net General Interview Questions

Explain what are the deferred execution and the immediate execution in linq?

1 Answers  


What is the difference between imperative and interrogative code?

1 Answers  


Do you know what is linq?

1 Answers  


Please explain when should you use .net web forms over asp.net mvc?

1 Answers  


What’s different between process and application in .net?

1 Answers  


How to send the Mail in C# using ASP.Net ? And my Answer is as follows ?

3 Answers   Intel,


Explain what are an object and a class?

1 Answers  


What is .net debug & trace?

1 Answers  


Tell us what is heap and what is stack?

1 Answers  


How is development of a Windows service different from a Windows Forms application?

1 Answers  


What are two different types of remote object creation mode in .net?

1 Answers  


what is the default value of CHAR type?in C# using asp.net?

7 Answers   Bosch,


Categories