Click here to Skip to main content
15,890,438 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: gridview Pin
Abhishek Sur29-Apr-10 23:57
professionalAbhishek Sur29-Apr-10 23:57 
AnswerRe: gridview Pin
Anurag Gandhi30-Apr-10 0:01
professionalAnurag Gandhi30-Apr-10 0:01 
GeneralRe: gridview Pin
Kissy1630-Apr-10 1:26
Kissy1630-Apr-10 1:26 
GeneralRe: gridview Pin
Brij30-Apr-10 1:39
mentorBrij30-Apr-10 1:39 
GeneralRe: gridview Pin
Abhijit Jana30-Apr-10 9:39
professionalAbhijit Jana30-Apr-10 9:39 
AnswerRe: gridview Pin
overtech0630-Apr-10 7:09
overtech0630-Apr-10 7:09 
GeneralRe: gridview Pin
Kissy1630-Apr-10 19:50
Kissy1630-Apr-10 19:50 
GeneralRe: gridview Pin
overtech061-May-10 5:33
overtech061-May-10 5:33 
Instead of binding the SQL command with the gridview, store the results of the SQL query that match your criteria in a dataset. Then bind the dataset with the gridview. I think this is what Abhishek was suggesting as well.

It would look something like:

// Create a dataset that represents the data you are retrieving from the database
DataSet myDataSet = new DataSet();
DataTable myDataTable = myDataTable.Tables.Add();
myDataTable.Columns.Add("ID", typeof(int));
myDataTable.Columns.Add("Foo", typeof(string));
myDataTable.Columns.Add("Bar", typeof(string));

// Execute your sql reader as normal
connection.Open();
SqlDataReader dr = cmd.ExecuteReader();
while(dr.Read())
{
    // instead of binding the reader, add the records you want to the dataset
    if (dr["myCriteria"].ToString() == "this")
    {
        myDataTable.Rows.Add(
            (int)dr["ID"],
             dr["Foo"].ToString(),
             dr["Bar"].ToString()
        );
    }
}
dr.Close();
connection.Close();

// Now bind the dataset you created to your GridView
myGridView.DataSource = myDataSet;
myGridView.BindData();


This could be done more elegantly by using myDataTable.Load(dr) then removing the rows that do not meet your criteria via a LINQ statement. But it should give you an idea of what you are trying to accomplish with a DataSet and get you started...

- Dave
AnswerRe: gridview Pin
Amit Patel198530-Apr-10 19:07
Amit Patel198530-Apr-10 19:07 
GeneralRe: gridview Pin
Kissy1630-Apr-10 19:42
Kissy1630-Apr-10 19:42 
QuestionHow to find all Created Items in a Repeater Pin
-Muc_29-Apr-10 21:29
-Muc_29-Apr-10 21:29 
AnswerRe: How to find all Created Items in a Repeater Pin
Abhishek Sur29-Apr-10 21:48
professionalAbhishek Sur29-Apr-10 21:48 
GeneralRe: How to find all Created Items in a Repeater Pin
-Muc_29-Apr-10 21:58
-Muc_29-Apr-10 21:58 
GeneralRe: How to find all Created Items in a Repeater Pin
Abhishek Sur29-Apr-10 22:01
professionalAbhishek Sur29-Apr-10 22:01 
GeneralRe: How to find all Created Items in a Repeater Pin
-Muc_29-Apr-10 22:27
-Muc_29-Apr-10 22:27 
GeneralRe: How to find all Created Items in a Repeater Pin
Abhishek Sur30-Apr-10 0:00
professionalAbhishek Sur30-Apr-10 0:00 
GeneralRe: How to find all Created Items in a Repeater Pin
-Muc_30-Apr-10 0:23
-Muc_30-Apr-10 0:23 
GeneralRe: How to find all Created Items in a Repeater Pin
-Muc_30-Apr-10 4:28
-Muc_30-Apr-10 4:28 
GeneralRe: How to find all Created Items in a Repeater Pin
Abhishek Sur30-Apr-10 5:49
professionalAbhishek Sur30-Apr-10 5:49 
QuestionFailed to find or load the registered .Net Framework Data Provider Pin
reogeo200829-Apr-10 21:19
reogeo200829-Apr-10 21:19 
AnswerRe: Failed to find or load the registered .Net Framework Data Provider Pin
Abhishek Sur29-Apr-10 21:52
professionalAbhishek Sur29-Apr-10 21:52 
QuestionI want to trigger an event of page (b) from page (a). How do I do that? Pin
tamilpuyal_2829-Apr-10 20:35
tamilpuyal_2829-Apr-10 20:35 
AnswerRe: I want to trigger an event of page (b) from page (a). How do I do that? Pin
Abhijit Jana29-Apr-10 20:45
professionalAbhijit Jana29-Apr-10 20:45 
AnswerRe: I want to trigger an event of page (b) from page (a). How do I do that? Pin
Abhishek Sur29-Apr-10 21:58
professionalAbhishek Sur29-Apr-10 21:58 
Questionhttp Basic authentication(RFC2617) Pin
kunaltilak29-Apr-10 20:28
kunaltilak29-Apr-10 20:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.