Hi,
Could someone help for this pls ?
Like in the gridView of the asp.net, I want to use the expression Text ='<%# Bind("xx") %>' in my templateItem column (Textbox in my case), so that the value that user enters in a textbox can be read in the datasource (it s a session datatable) in code behind in an automatic way :
Here is my item template which is defined in: <Columns> section of my WebDataGrid declaration:
<ig:TemplateDataField Width="250px" Key="bbbbbbbbbb"> <Header Text="Description"" /> <ItemTemplate> <asp:TextBox ID="Description" Columns="25" Text='<%# Bind("Description") %>' runat="server" TextMode="MultiLine" onkeydown="dirty()" onkeypress="event.returnValue=isMax_Length_256(event, this);"></asp:TextBox> </ItemTemplate> </ig:TemplateDataField>
The binding in code behind is done like this:
System.Data.DataTable dt = _provider.MainDataSource(); this.Session.Add("CurrentDataSource", dt);
myWebDataGrid.DataSource = this.Session["CurrentDataSource"];
this.myWebDataGrid.DataBind();
During binding process every thing works fine, I get the value into my textbox defined above. However, when I edit the text entering a new value, I don't get the new value in my session datatable variable.
Pls notice that the process works WELLwhen I don t put an itemtemplate with a textbox i-e if I only declare a bound fata field and use the Editing. However when I have an item template: I only get one way binding instead of two-way binding.
I am not sure if my editor behavior is taken into account either ?? here it's:
<ig:EditingCore> <Behaviors> <ig:CellEditing> <ColumnSettings> <ig:EditingColumnSetting ColumnKey="Description" /> <ig:EditingColumnSetting ColumnKey="projection" ReadOnly="true" /> <ig:EditingColumnSetting ColumnKey="pointe" ReadOnly="true" /> <ig:EditingColumnSetting ColumnKey="id" ReadOnly="true" /> <ig:EditingColumnSetting ColumnKey="scheduled" ReadOnly="true" /> <ig:EditingColumnSetting ColumnKey="offsetThreshold" ReadOnly="true" /> <ig:EditingColumnSetting ColumnKey="usageThreshold" ReadOnly="true" /> </ColumnSettings> <%--<CellEditingClientEvents EnteredEditMode="enteredEditMode" /> --%> </ig:CellEditing> <ig:RowDeleting Enabled="true" /> </Behaviors> </ig:EditingCore> <ig:Activation> </ig:Activation> <%--<ig:Selection RowSelectType="Single" Enabled="true" CellClickAction="Cell"></ig:Selection>--%> <%-- <ig:RowSelectors></ig:RowSelectors>--%>
</Behaviors> <EditorProviders> <ig:TextEditorProvider ID="PerfIndicatorContent_MultilineEditor"> <EditorControl runat="server" ID="editorm" TextMode="MultiLine"> <MultiLine Overflow="Scroll" Rows="3" /> </EditorControl> </ig:TextEditorProvider> </EditorProviders>
Thanks a lot for helping me with this one :)
Hi rtutus,
It has been some time since your post but in case that you still need assistance I will be happy to help.
I have made some research on the behavior you have described. It seems that when trying to update templated columns, the WebDataGrid RowUpdating event is not firing. In your case, I would suggest that you handle the TextChanged event of the textbox inside the ItemTemplate. There you could make necessary changes to the data source. For the non-templated columns you could either use the autoCRUD feature of the grid or implement the updating manually in the RowUpdating event handler. I am attaching a sample replicating your scenario. You can see that on ‘TextChanged’ event of the textbox the changes in the grid are transferred directly to the DataTable contained in the Session object. On initial page load the data source is added to the session and on every postback the grid is being bound to it.
If you need any further assistance on the matter please do not hesitate to ask.
Very interesting. Thank you very much Nikolay
Hello rtutus,
I'm glad I could help.
Please feel free to contact me if you have any other questions.