This question is locked. New answers and comments are not allowed.
New to telerik ... Please help me finding my controls (which i have added during runtime) inside gridboundcolumn...
This is my code snippet... I really appreciate your response...
This is my code snippet... I really appreciate your response...
<
telerik:RadGrid
ID
=
"gdCases"
runat
=
"server"
AutoGenerateColumns
=
"False"
CellSpacing
=
"0"
GridLines
=
"None"
EnableViewState
=
"True"
Skin
=
"Metro"
OnItemDataBound
=
"gdCases_ItemDataBound"
OnItemCreated
=
"gdCases_ItemCreated"
OnPreRender
=
"gdCases_PreRender"
AllowMultiRowEdit
=
"True"
><
br
><
br
> <
MasterTableView
EditMode
=
"InPlace"
DataKeyNames
=
"idCase,ComplaintStatus"
><
br
> <
CommandItemSettings
ShowAddNewRecordButton
=
"False"
/><
br
> <
Columns
><
br
> <
telerik:GridBoundColumn
DataField
=
"Tenant"
FilterControlAltText
=
"Filter colTenant column"
HeaderText
=
"Apt/Tenant"
UniqueName
=
"colTenant"
ReadOnly
=
"True"
><
br
> <
HeaderStyle
Font-Names
=
"Tahoma"
Font-Size
=
"Small"
HorizontalAlign
=
"Center"
Width
=
"120px"
/><
br
> </
telerik:GridBoundColumn
><
br
> <
br
> <
telerik:GridBoundColumn
DataField
=
"ComplaintStatus"
FilterControlAltText
=
"Filter colStatus column"
HeaderText
=
"Continue ?"
UniqueName
=
"colStatus"
ReadOnly
=
"True"
><
br
> <
HeaderStyle
HorizontalAlign
=
"Center"
Width
=
"120px"
/><
br
> <
ItemStyle
HorizontalAlign
=
"Center"
/><
br
> </
telerik:GridBoundColumn
><
br
> <
telerik:GridBoundColumn
DataField
=
"TotalArrearage"
FilterControlAltText
=
"Filter colLastOwed column"
HeaderText
=
"Last Owed"
UniqueName
=
"colLastOwed"
ReadOnly
=
"True"
><
br
> <
HeaderStyle
Font-Names
=
"Tahoma"
Font-Size
=
"Small"
HorizontalAlign
=
"Center"
Width
=
"120px"
/><
br
> <
ItemStyle
HorizontalAlign
=
"Right"
/><
br
> </
telerik:GridBoundColumn
><
br
> <
telerik:GridBoundColumn
DataField
=
"ComplaintTotalOwed"
FilterControlAltText
=
"Filter colCurrentOwed column"
HeaderText
=
"Current Owed"
UniqueName
=
"colCurrentOwed"
EmptyDataText
=
""
><
br
> <
HeaderStyle
Font-Names
=
"Tahoma"
Font-Size
=
"Small"
HorizontalAlign
=
"Center"
Width
=
"120px"
/><
br
> <
ItemStyle
HorizontalAlign
=
"Right"
/><
br
> </
telerik:GridBoundColumn
><
br
> <
telerik:GridBoundColumn
DataField
=
"idCase"
Display
=
"False"
FilterControlAltText
=
"Filter colCase column"
UniqueName
=
"colCase"
><
br
> <
HeaderStyle
Width
=
"1px"
/><
br
> <
ItemStyle
Font-Names
=
"Tahoma"
Font-Size
=
"Small"
HorizontalAlign
=
"Right"
/><
br
> </
telerik:GridBoundColumn
><
br
> </
Columns
><
br
> </
MasterTableView
><
br
> </
telerik:RadGrid
><
br
>
in aspx.cs
protected void gdCases_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item is GridDataItem)
{
GridEditableItem item = (GridEditableItem)e.Item;
RadioButton rdoYes = new RadioButton();
rdoYes.Text = "Yes";
rdoYes.GroupName = "group1";
RadioButton rdoNo = new RadioButton();
rdoNo.Text = "No";
rdoNo.GroupName = "group1";
if (item["colStatus"].Text == "Continue")
rdoYes.Checked = true;
else
rdoNo.Checked = false;
item["colStatus"].Controls.Add(rdoYes);
item["colStatus"].Controls.Add(rdoNo);
TextBox totalOwed = new TextBox();
totalOwed.Style["text-align"] = "right";
totalOwed.Width = 120;
if (item["colCurrentOwed"].Text != "")
totalOwed.Text = item["colCurrentOwed"].Text.Trim();
else
totalOwed.Text = String.Empty;
totalOwed.Text.Replace(" ", String.Empty);
item["colCurrentOwed"].Controls.Add(totalOwed);
}
}
On btnClick - Save
protected void btnSave_Click(object sender, EventArgs e)
{
foreach (GridDataItem item in gdCases.MasterTableView.Items)
{
TableCell cellCurrentOwed = item["colCurrentOwed"];
string totalOwed = (cellCurrentOwed.Controls[0] as TextBox).Text; --GETTING ERROR
TableCell cellColStatus = item["colStatus"];
RadioButton rdoY = (RadioButton)item.FindControl("rdoYes"); --GETTING ERROR
TableCell cellStatus = item["colStatus"];
Boolean statusChecked = (cellStatus.Controls[0] as RadioButton).Checked; --GETTING ERROR
String itemStatus = "";
if (statusChecked)
itemStatus = "Continue";
else
itemStatus = "Discontinue";