hello to all expert
Good day! i would like again to ask some help coz i dont know how i'am going to put a combobox on every row on the grid that is also binded to the database..please help.
sample codes si highly appreciated
thanks to all
Good day! i would like again to ask some help coz i dont know how i'am going to put a combobox on every row on the grid that is also binded to the database..please help.
sample codes si highly appreciated
thanks to all
5 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 29 Apr 2009, 09:36 AM
Hello Jols,
You can either use a GridDropDownColumn or use a GridTemplateColumn with a RadComboBox in its ItemTemplate as shown below:
aspx:
Also refer to the following link to understand teh different types of columns available within RadGrid.
Column types
Thanks
Princy.
You can either use a GridDropDownColumn or use a GridTemplateColumn with a RadComboBox in its ItemTemplate as shown below:
aspx:
| <telerik:GridDropDownColumn DropDownControlType="RadComboBox" DataSourceID="SqlDataSource1" ListTextField="DataFieldName" > |
| </telerik:GridDropDownColumn> |
| (OR) |
| <telerik:GridTemplateColumn UniqueName="TempColumn"> |
| <ItemTemplate> |
| <telerik:RadComboBox ID="RadComboBox1" DataSourceID="SqlDataSource1" DataTextField="DataFieldName" runat="server"> |
| </telerik:RadComboBox> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
Column types
Thanks
Princy.
0
Jols
Top achievements
Rank 2
answered on 29 Apr 2009, 09:50 AM
sir how am i going to get the selected value on the radcombobox in the grid?
0
Shinu
Top achievements
Rank 2
answered on 29 Apr 2009, 10:02 AM
Hi,
When using a TemplateColumn, then you can set the selected value as shown below:
And for getting the SelectedValue, either you can use the SelectedIndexChanged event of RadComboBox (when AutoPostBack is set to True) or in PreRender event of RadGrid as shown below.
CS:
Thanks
Shinu.
When using a TemplateColumn, then you can set the selected value as shown below:
| <telerik:GridTemplateColumn UniqueName="TempColumn"> |
| <ItemTemplate> |
| <telerik:RadComboBox ID="RadComboBox1" SelectedValue='<%#Eval("Name") %>' DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="Name" runat="server"> |
| </telerik:RadComboBox> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
And for getting the SelectedValue, either you can use the SelectedIndexChanged event of RadComboBox (when AutoPostBack is set to True) or in PreRender event of RadGrid as shown below.
CS:
| protected void RadGrid1_PreRender(object sender, EventArgs e) |
| { |
| foreach (GridDataItem item in RadGrid1.Items) |
| { |
| RadComboBox combo = (RadComboBox)item.FindControl("RadComboBox1"); |
| string str = combo.SelectedItem.Value; |
| } |
| } |
Thanks
Shinu.
0
Jols
Top achievements
Rank 2
answered on 29 Apr 2009, 10:54 AM
| <telerik:GridTemplateColumn HeaderText="Banks" UniqueName="colBanksList" |
| > |
| <ItemTemplate> |
| <telerik:radcombobox id="comboBanks" runat="server" |
| autopostback="false" |
| cssclass="textContent" |
| SelectedValue='<%# Eval("fxMemberKey") %>' |
| DataValueField ="fxMemberKey" |
| DataTextField ="fcBusinessName" |
| skin="Office2007" > |
| <CollapseAnimation Type="OutQuint" Duration="200"> |
| </CollapseAnimation> |
| </telerik:radcombobox> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn DataField="fxMemberKey" |
| HeaderText="fxMemberKey" SortExpression="fxMemberKey" |
| UniqueName="fxMemberKey" Visible="False"> |
| </telerik:GridBoundColumn> |
| C# |
| protected void rgridAccessRights_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) |
| { |
| if (e.Item is GridDataItem) |
| { |
| DataTable rs = LoadBanks(); //Procedure calling stored Proc |
| GridDataItem item = (GridDataItem)e.Item; |
| RadComboBox ddl = (RadComboBox)item["colBanksList"].FindControl("comboBanks"); |
| ddl.Items.Clear(); |
| ddl.SelectedValue = null; |
| ddl.DataSource = rs; |
| ddl.DataTextField = "fcBusinessName"; |
| ddl.DataValueField = "fxMemberKey"; |
| ddl.DataBind(); |
| ddl.Items.Insert(0, new RadComboBoxItem("--Select--")); |
| } |
| } |
| private void SetGridData(string sKeyID) |
| { |
| AppGlobalDeclarations gConn = new AppGlobalDeclarations(); |
| ConnStrings cConString = new ConnStrings(); |
| ErrorHandler cError = new ErrorHandler(); |
| MasterUserType cUserType = new MasterUserType(); |
| DataTable dt = new DataTable(); |
| try |
| { |
| cConString.SQLConnectionString = gConn.SQLConnection; |
| cUserType.TypeConnectString = cConString; |
| dt = cUserType.tblUserType08ModulesRights_GetByLevel(sKeyID); |
| cError = cUserType.MasterUserTypeError; |
| if (cError.ErrStatus) |
| { |
| string msg = "Error on Module:" + cError.ErrMethod + ":" + cError.ErrMessage; |
| this.Response.Redirect("../CustomErrorPage.aspx?ErrorMessage=" + msg); |
| } |
| else |
| { |
| this.rgridAccessRights.DataSource = dt; |
| this.rgridAccessRights.DataBind(); |
| //CreateGridCheckColumns(); |
| } |
| } |
| catch (Exception ex) |
| { |
| string msg = "Error on Module:" + "Load Module List" + ":" + ex.Message.ToString(); |
| this.Response.Redirect("../CustomErrorPage.aspx?ErrorMessage=" + msg); |
| } |
| } |
| I'm having a problem when i tried to select an item on the radcombobox on the grid..here's the error: Redirect URI cannot contain newline characters..please help |
0
Jols
Top achievements
Rank 2
answered on 29 Apr 2009, 11:38 AM
sir this the content of that error... Selection out of range
Parameter name: value
what is the possible solution for that error sir..please help
sample codes is higly appreciated
thanks
Parameter name: value
what is the possible solution for that error sir..please help
sample codes is higly appreciated
thanks