I am using Devexpress.Aspx Gridview control. I have an AspxGridview that shows the following data.
1. Gallery Name
2. Gallery (Image Column)
3. Display Order
In "Display Order" column i have to get the input from the user to display the images in that order. So i used a column that is the Template of DataItemTemplat e (Textbox Template). I successfully bound the values to the columns. After editing the values and click on save button I am not able to get the Control from the "Display Order" column. That return null.
But if i use the same code while loading the grid and trace the code, I am getting the Control and its values.
Why i am not getting the control and its values after binding the grid? Can anyone help me?
See my code below.
Thanks in advance. I hope you can help me....
1. Gallery Name
2. Gallery (Image Column)
3. Display Order
In "Display Order" column i have to get the input from the user to display the images in that order. So i used a column that is the Template of DataItemTemplat e (Textbox Template). I successfully bound the values to the columns. After editing the values and click on save button I am not able to get the Control from the "Display Order" column. That return null.
But if i use the same code while loading the grid and trace the code, I am getting the Control and its values.
Why i am not getting the control and its values after binding the grid? Can anyone help me?
See my code below.
Code:
public class TextBoxTemplateColumn : ITemplate
{
public void InstantiateIn(Control container)
{
GridViewDataItemTemplateContainer gcontainer = (GridViewDataItemTemplateContainer)container;
DevExpress.Web.ASPxEditors.ASPxTextBox txt = new DevExpress.Web.ASPxEditors.ASPxTextBox();
txt.ID = "txtDisplayOrder";
txt.Width = 250;
txt.MaxLength = 5;
txt.Text = (gcontainer.Text.ToString() == "999999") ? string.Empty : gcontainer.Text.ToString();
container.Controls.Add(txt);
}
}
private void BindHomeGallery()
{
List objList = new ManageHomeGallery().FetchAllGallery();
TextBoxTemplateColumn txtTemp = new TextBoxTemplateColumn();
DevExpress.Web.ASPxGridView.GridViewDataTextColumn gcDisplayOrder = new DevExpress.Web.ASPxGridView.GridViewDataTextColumn();
gcDisplayOrder.Name = "DisplayOrder";
gcDisplayOrder.Caption = "DisplayOrder";
gcDisplayOrder.FieldName = "DisplayOrder";
gcDisplayOrder.UnboundType = DevExpress.Data.UnboundColumnType.String;
gcDisplayOrder.Visible = true;
gcDisplayOrder.VisibleIndex = 2;
gcDisplayOrder.DataItemTemplate = txtTemp;
grdvwManageHomeGallery.Columns.Add(gcDisplayOrder);
grdvwManageHomeGallery.DataSource = dtGallery;
grdvwManageHomeGallery.DataBind();
}
This is the line i use to get the control and access its values.
DevExpress.Web.ASPxEditors.ASPxTextBox txtDisplayOrder =(DevExpress.Web.ASPxEditors.ASPxTextBox) grdvwManageHomeGallery.FindRowCellTemplateControl(e.VisibleIndex, (DevExpress.Web.ASPxGridView.GridViewDataTextColumn)grdvwManageHomeGallery.Columns["DisplayOrder"], "txtDisplayOrder");
Thanks in advance. I hope you can help me....