Hi
i want to bind a datasource to a Griddropdown column but when i bind it , but i face with some error like that reference to null object
here is my Aspx code:
and here is my Cs code:
Do u know why?
i want to bind a datasource to a Griddropdown column but when i bind it , but i face with some error like that reference to null object
here is my Aspx code:
| <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> |
| <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head runat="server"> |
| <title>Untitled Page</title> |
| <style type="text/css"> |
| .RadGrid_Default |
| { |
| border:1px solid #232323; |
| } |
| .RadGrid_Default |
| { |
| font:11px/1.4 arial,sans-serif; |
| } |
| .RadGrid_Default |
| { |
| background:#d4d0c8; |
| color:#333; |
| } |
| .MasterTable_Default |
| { |
| background:#fff; |
| border-collapse:separate !important; |
| } |
| .MasterTable_Default |
| { |
| font:11px/1.4 arial,sans-serif; |
| } |
| .GridHeader_Default |
| { |
| color:#fff; |
| text-decoration:none; |
| } |
| .GridHeader_Default |
| { |
| border-bottom:1px solid #010101; |
| background:url('mvwres://Telerik.Web.UI, Version=2008.3.1105.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.headers.gif') repeat-x #434343; |
| padding:10px 6px 10px 11px; |
| text-align:left; |
| font-size:1.3em; |
| font-weight:normal; |
| } |
| .GridHeader_Default a |
| { |
| color:#fff; |
| text-decoration:none; |
| } |
| .RadGrid_Default .rgFilter |
| { |
| background-position:2px -897px; |
| } |
| .RadGrid_Default .rgFilter |
| { |
| width:16px; |
| height:16px; |
| border:0; |
| padding:0; |
| background-color:transparent; |
| background-image:url('mvwres://Telerik.Web.UI, Version=2008.3.1105.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.sprite.gif'); |
| background-repeat:no-repeat; |
| vertical-align:middle; |
| cursor:pointer; |
| } |
| </style> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <div> |
| <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> |
| </telerik:RadAjaxManager> |
| </div> |
| <asp:ScriptManager ID="ScriptManager1" runat="server"> |
| </asp:ScriptManager> |
| <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" |
| onprerender="RadGrid1_PreRender"> |
| <HeaderContextMenu EnableTheming="True"> |
| <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
| </HeaderContextMenu> |
| <MasterTableView AutoGenerateColumns="False" DataKeyNames="source_code,source_row"> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridBoundColumn DataField="source_code" DataType="System.Decimal" |
| HeaderText="source_code" ReadOnly="True" SortExpression="source_code" |
| UniqueName="source_code"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="source_row" DataType="System.Decimal" |
| HeaderText="source_row" ReadOnly="True" SortExpression="source_row" |
| UniqueName="source_row"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="activity_id" DataType="System.Decimal" |
| HeaderText="activity_id" SortExpression="activity_id" UniqueName="activity_id"> |
| </telerik:GridBoundColumn> |
| <telerik:GridDropDownColumn UniqueName="source_desc" DataSourceID="SqlDataSource1" |
| SortExpression="source_desc" ListTextField="lookup_nm" ListValueField="lookup_cd" |
| HeaderText="Title of courtesy" DataField="source_desc" DropDownControlType="RadComboBox" > |
| </telerik:GridDropDownColumn> |
| </Columns> |
| </MasterTableView> |
| <FilterMenu EnableTheming="True"> |
| <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
| </FilterMenu> |
| </telerik:RadGrid> |
| <asp:SqlDataSource ID="SqlDataSource1" runat="server" |
| ConnectionString="<%$ ConnectionStrings:OrdersConnectionString %>" |
| SelectCommand="SELECT [lookup_cd], [lookup_nm] FROM [PB_lookup] WHERE ([lookup_id] = 'PB_source_header.company_typ_id')"> |
| <SelectParameters> |
| <asp:Parameter Name="lookup_id" Type="String" /> |
| </SelectParameters> |
| </asp:SqlDataSource> |
| </form> |
| </body> |
| </html> |
| public partial class _Default : System.Web.UI.Page |
| { |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| RadGrid1.MasterTableView.CommandItemDisplay = Telerik.Web.UI.GridCommandItemDisplay.TopAndBottom; |
| DataSet ds = new DataSet(); |
| SqlCommand cmd = new SqlCommand("Select * From PB_source_detail"); |
| SqlConnection mycon = new SqlConnection("Data Source=MONO-PC\\SQLEXPRESS;Initial Catalog=Orders;Integrated Security=True"); |
| mycon.Open(); |
| SqlDataAdapter SDA = new SqlDataAdapter(cmd.CommandText, mycon); |
| SDA.Fill(ds); |
| RadGrid1.DataSource = ds.Tables[0]; |
| mycon.Close(); |
| } }} |