SqlCommand sql =
new SqlCommand();
SqlDataAdapter da =
new SqlDataAdapter();
string connectionString = WebConfigurationManager.ConnectionStrings["SBF"].ToString();
SqlConnection con =
new SqlConnection(connectionString);
//ConfigurationManager.ConnectionStrings[connectionString]
con.ConnectionString = connectionString;
sql.CommandText =
@"select A from SSA";
sql.Connection = con;
da.SelectCommand = sql;
DataTable dt =
new DataTable();
List<int> ints = new List<int>();
da.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
ints.Add(
Convert.ToInt32(dt.Rows[i]["A"]));
}
RadGrid1.DataSource = ints;
I am using the 2009.3.1208.35 version of the Telerik.Web.UI.
Thanks,
Jonathan Simon

I want to set the DataTextField of a RadComboBox at pageload according to the users prefered language - and keep that value.
So far my code looks like this:
(a small part of the mastertableview of the grid RadGridVehicle)
| <telerik:GridDropDownColumn DataSourceID="sdsHaulierType" |
| DataField="HaulierType" DataType="System.Int32" |
| HeaderText="Haulier type" |
| ReadOnly="true" |
| ListTextField="HaulierTypeName" |
| ListValueField="HaulierTypeID" |
| DropDownControlType="DropDownList" |
| SortExpression="HaulierType" |
| UniqueName="HaulierType" |
| EditFormColumnIndex="0" |
| Visible="true" ForceExtractValue="Always" > |
| <FilterTemplate> |
| <telerik:RadComboBox ID="cbHaulierType" runat="server" |
| AppendDataBoundItems="true" |
| DataSourceID = "sdsHaulierType" |
| DataValueField = "HaulierTypeID" |
| DataTextField = "HaulierTypeName" |
| SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("HaulierType").CurrentFilterValue %>' |
| OnClientSelectedIndexChanged="HaulierTypeChanged"> |
| <Items> |
| <telerik:RadComboBoxItem Text="All" /> |
| </Items> |
| </telerik:RadComboBox> |
| <telerik:RadScriptBlock ID="sbHaulierType" runat="server"> |
| <script type="text/javascript"> |
| function HaulierTypeChanged(sender,args) |
| { |
| var tableView=$find("<%# ((GridItem)Container).OwnerTableView.ClientID %>"); |
| tableView.filter("HaulierType",args.get_item().get_value(),"EqualTo"); |
| } |
| </script> |
| </telerik:RadScriptBlock> |
| </FilterTemplate> |
| </telerik:GridDropDownColumn> |
| <asp:SqlDataSource ID="sdsHaulierType" runat="server" |
| ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" |
| SelectCommand="SELECT * FROM [HaulierType]"> |
| </asp:SqlDataSource> |
| protected void RadGridVehicle_Load(object sender, EventArgs e) |
| { |
| ddc = (GridDropDownColumn)RadGridVehicle.MasterTableView.Columns.FindByUniqueName("HaulierType"); |
| if (userLang == "da") |
| { |
| ddc.ListTextField = "DAHaulierType"; |
| } |
| else if (userLang == "sv") |
| { |
| ddc.ListTextField = "SVHaulierType"; |
| } |
| } |
| Protected Sub txtEditPileDia_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) |
| Try |
| objDetailInfo = New NDSBLL.DetailInfo |
| objDetailDal = New NDSDAL.DetailDal |
| Dim txtNewPileDia As TextBox |
| Dim txtLinkStart As TextBox |
| Dim txtLinkEnd As TextBox |
| 'Dim txtAdditionalSpiral As TextBox |
| Dim intIndex As Integer = ???? |
| txtNewPileDia = DirectCast(gvStructDetails.Rows(intIndex).FindControl("txtPileDia"), TextBox) |
| txtLinkStart = DirectCast(gvStructDetails.Rows(intIndex).FindControl("txtEditNoLinksStart"), TextBox) |
| txtLinkEnd = DirectCast(gvStructDetails.Rows(intIndex).FindControl("txtEditNoLinksEnd"), TextBox) |
| 'txtAdditionalSpiral = DirectCast(gvStructDetails.Rows(intIndex).FindControl("txtEditNoAdditionalSpiral"), TextBox) |
| If ((Not txtLinkStart Is Nothing) And (Not txtLinkEnd Is Nothing) And (Not txtNewPileDia Is Nothing)) Then |
| PopulateLinksValues(txtNewPileDia, txtLinkStart, txtLinkEnd) |
| End If |
| Catch ex As Exception |
| ErrorHandler.RaiseError(ex, strPath) |
| End Try |
| End Sub |
| Protected Sub DataList_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataList.ItemDataBound |
| Select Case e.Item.ItemType |
| Case ListItemType.Item, ListItemType.AlternatingItem |
| Dim myRow As DataRowView = CType(e.Item.DataItem, DataRowView) |
| Dim hype As HyperLink = e.Item.FindControl("DatalistHyperlink") |
| If myRow.Item("category") = "General" Then |
| hype.NavigateUrl = "default.aspx?NewsID=" & myRow.Item("NewsID") |
| Else |
| hype.NavigateUrl = "subpages/" & myRow.Item("category") & ".aspx?NewsID=" & myRow.Item("NewsID") |
| End If |
| End Select |
| End Sub |