Hello,
I'm attempting to use the advanced databind feature and the NeedDataSource and cant seem to get the event to fire.
I was having trouble getting it to launch in an existing page so I created a new content page (based on a simplistic Master page), dropped a grid on the page, configured a couple columns via the Property Builder, then added the NeedDataSource contruct...
...and no data is in the grid. I know that the select coding works because its a copy of the method I was calling from the Page_Load event to populate the grid before trying the advanced binding option. The message box in the snippet never even fires. The grid is set to Visible and, in this example, was never bound to any data source.
Any help would be appreciated.
Thanks in advance,
Rick
I'm attempting to use the advanced databind feature and the NeedDataSource and cant seem to get the event to fire.
I was having trouble getting it to launch in an existing page so I created a new content page (based on a simplistic Master page), dropped a grid on the page, configured a couple columns via the Property Builder, then added the NeedDataSource contruct...
| protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) |
| { |
| SqlConnection myConn = new SqlConnection(ConfigurationSettings.AppSettings["SQLConnectionString"]); |
| SqlDataAdapter da = new SqlDataAdapter(); |
| DataSet ds = new DataSet(); |
| MessageBox.Show("Blah"); |
| try |
| { |
| myConn.Open(); |
| da.SelectCommand = new SqlCommand("select *, DateDiff(d,TimeStamp,GetDate()) as DaysOld, DateDiff(m,TimeStamp,GetDate()) as MonthsOld,RANK() OVER (order by TIMESTAMP) as RowNumber from ReadHistory where CardID = 'ABC00002' order by TimeStamp", myConn); |
| da.Fill(ds, "ReadData"); |
| DataView dv = ds.Tables["ReadData"].DefaultView; |
| Session["ReadData"] = dv; |
| RadGrid1.DataSource = dv; |
| } |
| catch (Exception ex) |
| { |
| MessageBox.Show("Error Loading Data: " + ex.Message.ToString()); |
| } |
| finally |
| { |
| myConn.Close(); |
| } |
| } |
...and no data is in the grid. I know that the select coding works because its a copy of the method I was calling from the Page_Load event to populate the grid before trying the advanced binding option. The message box in the snippet never even fires. The grid is set to Visible and, in this example, was never bound to any data source.
Any help would be appreciated.
Thanks in advance,
Rick