Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Asksuresh Programmer   on Nov 27 In Asp.net Category.

  
Question Answered By: Abbas Hashmi   on Nov 27

Where you have this code  in the page load event


DataGrid1.DataSource = myDataSet
DataGrid1.DataMember = "Tabel"
DataGrid1.DataBind()
Session("data") = myDataSet


You are setting the datasource  and then calling the databind() method

When you call the dataBind() immediately, the onItemDataBound event is
called for each row of data.



In the itemDataBoundEvent, you are attempting to retrieve the dataset
from the session variable but at this point, when the page is first
loaded, you have not put anything in the session variable, when you
attempt to get the table from the dataset  hence the error.

If I change the code in the page load event to look like this instead,

Session("data") = myDataSet
DataGrid1.DataSource = myDataSet
DataGrid1.DataMember = "Tabel"
DataGrid1.DataBind()

Now when the item data  bound event is called, I am sure to have the data
in the session variable.

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on binding dropdownlist to datagrid Or get search suggestion and latest updates.


Tagged: