Hi,
I am using Ultrawebgrid 6 version.
Is it possible to bind grid cell on first row first column with drop down and second row first column with datetime editor or any other control? If yes then how?
Hello,
Please take a look at the link below:http://news.infragistics.com/forums/p/11822/44629.aspx#44629
Hope this helps.
i have added controls in cell template and made those invisible. now at runtime i decide which one to set visible. that is working okay. But when i write any value in these controls and try to access the value from server, i am not getting the value over there? what can be the reason?
Giving the code on server side while saving my data.
ig.TemplatedColumn col = (ig.TemplatedColumn)gRow.Cells.FromKey("FilterValue1").Column;
ig.CellItem ci = (ig.CellItem)col.CellItems[gRow.Index];
DropDownList ddl = (DropDownList)ci.FindControl("ddlVal");
DropDownList ddlBool = (DropDownList)ci.FindControl("ddlValBoolean");
TextBox txt = (TextBox)ci.FindControl("txtVal");
Infragistics.WebUI.WebDataInput.WebNumericEdit wne = (Infragistics.WebUI.WebDataInput.WebNumericEdit)ci.FindControl("numVal");
Infragistics.WebUI.WebDataInput.WebDateTimeEdit wdte = (Infragistics.WebUI.WebDataInput.WebDateTimeEdit)ci.FindControl("dtpVal");
if (ddl.Visible) { rowFilterFld.FilterValue1 = ddl.SelectedValue; }
else if (ddlBool.Visible) { rowFilterFld.FilterValue1 = ddlBool.SelectedValue; }
else if (txt.Visible) { rowFilterFld.FilterValue1 = txt.Text; }
else if (wne.Visible) { rowFilterFld.FilterValue1 = wne.Value.ToString(); }
else if (wdte.Visible) { rowFilterFld.FilterValue1 = wdte.Value.ToString(); }
I am not sure I understand the complete scenario in details, but I think the following technique for getting controls inside template and switching them in IntislizeRow based on the runtime scenario will help:
http://forums.infragistics.com/forums/t/22474.aspx
Scenario:
I need to dynamically change the control within a cell according to first cell value. For example if i have "T" in first cell then i need to show textbox in last column. IF "B" then drop down and for "D" i need to show DateTime picker in last cell of active row.
I have placed all possible controls in cell template and made them invisible. Now i set controls visibility according to first cell value.
I have achieved it through infragistics help already. But now i am facing a problem when i try to read any value from these control on server side. These controls are not keeping their values. If i type any text in "Textbox" but on server side "Text" property is empty.
ASPX
<igtbl:TemplatedColumn BaseColumnName="FilterValue1" DataType="System.String" IsBound="true"Key="FilterValue1">
<Header Caption="Value" />
<CellTemplate>
<asp:DropDownList ID="ddlVal" runat="server" Visible="false" SkinID="FilterDDL" EnableViewState="true" />
<igtxt:WebDateTimeEdit ID="dtpVal" runat="server" Visible="false" SkinID="Filter"
EnableViewState="true" />
<igtxt:WebNumericEdit ID="numVal" runat="server" Visible="false" SkinID="FilterNumeric"
<asp:TextBox ID="txtVal" runat="server" Visible="false" SkinID="Filtertxt" EnableViewState="true" />
<asp:DropDownList ID="ddlValBoolean" runat="server" Visible="false" SkinID="FilterDDL" EnableViewState="true">
<asp:ListItem Value="false" Text="No" />
<asp:ListItem Value="true" Text="Yes" />
</asp:DropDownList>
</CellTemplate>
</igtbl:TemplatedColumn>
C#
if (ddl.Visible) { rowFilterFld.FilterValue1 = ddl.SelectedValue; } <==================== Value is empty
else if (txt.Visible) { rowFilterFld.FilterValue1 = txt.Text; } <============== Text is empty here.
I may have some help for you.
I use the page load event and NOT ispostback to set up the grid.
I determine which template control to use based on the value of another cell.
on postback through a button control, I go through the row collection looking at each template control I assigned previously and assigning THAT value to the cell I want..
Here is a sample:
.Load
Then
UltraWebGrid1.DataSource = GetData()
UltraWebGrid1.DataBind()
), Infragistics.WebUI.UltraWebGrid.TemplatedColumn)
Infragistics.WebUI.UltraWebGrid.CellItem
'' Loop through all the rows.. find out WHICH fieldtype we are using then make appropriate control visible and assign value
'************************************************
UltraWebGrid1.Rows
ci = t.CellItems(r.Index)
), Infragistics.WebUI.WebDataInput.WebDateTimeEdit)
DT.Value = r.Cells.FromKey(
).Value
DT.Visible =
True
Else
), Infragistics.WebUI.WebDataInput.WebTextEdit)
b.Value = r.Cells.FromKey(
b.Visible =
If
Next
On post back I do the same routine but switch the t controls and cell
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
'this part now works
For Each r As UltraGridRow In UltraWebGrid1.Rows
Dim t As Infragistics.WebUI.UltraWebGrid.TemplatedColumn = TryCast(Me.UltraWebGrid1.Columns.FromKey("CurrentValues"), Infragistics.WebUI.UltraWebGrid.TemplatedColumn)
Dim ci As Infragistics.WebUI.UltraWebGrid.CellItem = t.CellItems(r.Index)
If r.Cells.FromKey("ParameterType").Value.ToString.Contains("Date") Then
Dim DT As Infragistics.WebUI.WebDataInput.WebDateTimeEdit = DirectCast(ci.FindControl("WebDateTimeEdit1"), Infragistics.WebUI.WebDataInput.WebDateTimeEdit)
r.Cells.FromKey(
"CurrentValues").Value = DT.Value
Dim b As Infragistics.WebUI.WebDataInput.WebTextEdit = DirectCast(ci.FindControl("WebTextEdit1"), Infragistics.WebUI.WebDataInput.WebTextEdit)
"CurrentValues").Value = b.Value
End If
End
This takes the value of the template control and assignes it to the cell.
Sub
If you ever find the answer to this question, I would like to know. I have had no luck with infragistics.
They either give me information I already know or point me to examples that are useless, because the don't answer the question.
Thanks for your quick respone.
I have verified if i am somewhere rebinding the grid but it is not so. Basicially this page is a wizard control. and on step 2 of this wizard i am using dynamic controls in last column. its values are retained when i navigate between steps but it loses values when i go for saving. Its givning me a really hard time. Your help in this regard will be highly appreciated.
Kindly send me any proved such example where we can read values on server side from cellTemplate custom controls.
This problem typically happens when you are rebinding the grid prior to accessing the values in the templates. Rebinding the grid clears all information and settings, including values of nested controls.
Rebinding can occur implicitly, in the case where you are using InitializeDataSource. Is this the case?