I have controls inside form template or radgrid. When click on the edit button i am able to get the controls which are present inside <formtemplate> of grid inside DataBound() event. But when I click on Add new record option I am unable to find the controls id in RadGrid_DataBound() event.
So Please tell me how I fix this as soon as possible.
Its very urgent.
Thanks,
Monalisa
3 Answers, 1 is accepted
Can you please verify that you are using advanced binding intercepting the NeedDataSource event of the grid?
Note that operations like data editing, grouping, etc. require such type of binding as opposed to the standard simple GridView binding with DataBind() calls.
Kind regards,
Pavlina
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Following is my code snippet.
<
form id="form1" runat="server">
<asp:ScriptManager ID="sc" runat="server"></asp:ScriptManager>
<radG:RadGrid ID="RadGrid1"
Skin="Vista"
runat="server"
GridLines="None"
AllowPaging="True"
PageSize="5"
AllowSorting="True"
Width="99%"
AutoGenerateColumns="False"
EnableAJAX="True"
ShowStatusBar="True"
OnNeedDataSource="RadGrid1_NeedDataSource"
OnUpdateCommand="RadGrid1_UpdateCommand"
OnInsertCommand="RadGrid1_InsertCommand"
OnDeleteCommand="RadGrid1_DeleteCommand"
ondatabound="RadGrid1_DataBound"
onitemdatabound="RadGrid1_ItemDataBound">
<HeaderContextMenu Skin="Vista" EnableTheming="True">
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
</HeaderContextMenu>
<PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
<MasterTableView CommandItemDisplay="Top" GridLines="None"
DataKeyNames="PK_ID" EditMode="EditForms">
<Columns>
<radG:GridEditCommandColumn>
</radG:GridEditCommandColumn>
<radG:GridBoundColumn UniqueName="PK_ID"
HeaderText="ID"
ReadOnly="true"
DataField="PK_ID">
</radG:GridBoundColumn>
<radG:GridTemplateColumn HeaderText="TempCol" UniqueName="TempCol">
<EditItemTemplate>
<radG:RadComboBox ID="radComboMedicalHx"
runat="server"
AllowCustomText="True"
MarkFirstMatch="True" Width="255px"
Skin="Office2007" >
</radG:RadComboBox>
</EditItemTemplate>
</radG:GridTemplateColumn>
<radG:GridBoundColumn UniqueName="Name"
HeaderText="Medical Problem"
DataField="Name">
</radG:GridBoundColumn>
<radG:GridBoundColumn UniqueName="DATE_ON_SET"
HeaderText="Date Of Onset"
DataField="DATE_ON_SET">
</radG:GridBoundColumn>
<radG:GridBoundColumn UniqueName="DATE_RESOLVED"
HeaderText="Date Resolved"
DataField="DATE_RESOLVED">
</radG:GridBoundColumn>
<radG:GridBoundColumn UniqueName="COMMENTS"
HeaderText="Comments"
DataField="COMMENTS">
</radG:GridBoundColumn>
<radG:GridButtonColumn CommandName="Delete" Text="Delete">
</radG:GridButtonColumn>
</Columns>
<EditFormSettings EditFormType="Template">
<EditColumn UniqueName="EditCommandColumn1">
</EditColumn>
<FormTemplate>
<table id="Table2" cellspacing="2" cellpadding="1" border="1" rules="none"
style="border-collapse: collapse" width="50%">
<tr>
<td>
<table id="Table3" cellspacing="1" cellpadding="1" width="100%" border="0" >
<tr>
<td colspan="2">
<asp:TextBox ID="txtID" MaxLength=5 Visible='<% # (Container as GridItem).OwnerTableView.IsItemInserted %>' runat="server" style="display:none">
</asp:TextBox>
<asp:TextBox ID="txtHidId" runat="server" Text='<%# Eval( "PK_ID") %>' Visible="false"></asp:TextBox>
</td>
</tr>
<tr>
<td>Search Code:
</td>
<td>
<asp:TextBox ID="txtSearch" runat="server"
SkinID="NormalTextbox"
ontextchanged="txtSearch_TextChanged"
onkeypress="return CheckEnterKeyValue(event,this);" AutoPostBack="true"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Codes :
</td>
<td>
<asp:DropDownList ID="drpCodes" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="drpCodes_SelectedIndexChanged"
SkinID="NormalDropDown">
<asp:ListItem Value="1" >Preferred Codes</asp:ListItem>
<asp:ListItem Value="2">Standard Codes</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Medical Problem:
</td>
<td>
<radG:RadComboBox ID="radComboMedicalHx"
runat="server"
AllowCustomText="True"
MarkFirstMatch="True" Width="255px"
Skin="Office2007" >
</radG:RadComboBox>
</td>
</tr>
<tr>
<td>
<asp:CheckBox ID="chkAddPreferredCode" runat="server"
Text=" Add To Preferred Code" Visible="false"
>
</asp:CheckBox>
</td>
<td>
<asp:TextBox ID="txtAddPreferredCode" runat="server"
SkinID="NormalTextbox" Visible="false"
></asp:TextBox>
</td>
</tr>
<tr>
<td>
Date On Set:
</td>
<td>
<asp:TextBox ID="txtDateOnSet" runat="server"
Text='<%# Eval( "DATE_ON_SET") %>'
TabIndex="1">
</asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtenderOnset" runat="server"
Enabled="True" TargetControlID="txtDateOnSet">
</cc1:CalendarExtender>
</td>
</tr>
<tr>
<td>
Date Resolved:
</td>
<td>
<asp:TextBox ID="txtDateResolved" runat="server"
Text='<%# Eval( "DATE_RESOLVED") %>'
TabIndex="2">
</asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server"
Enabled="True" TargetControlID="txtDateResolved">
</cc1:CalendarExtender>
</td>
</tr>
<tr>
<td>
Comments:
</td>
<td>
<asp:TextBox ID="txtComments" runat="server"
Text='<%# Eval( "COMMENTS") %>'
TabIndex="2" TextMode="MultiLine">
</asp:TextBox></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="btnUpdate" Text='<%# (Container as GridItem).OwnerTableView.IsItemInserted ? "Insert" : "Update" %>'
runat="server" CommandName='<%# (Container as GridItem).OwnerTableView.IsItemInserted ? "PerformInsert" : "Update" %>'>
</asp:Button>
<
asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
CommandName
="Cancel"></asp:Button></td>
</tr>
</table>
</FormTemplate>
</EditFormSettings>
<ExpandCollapseColumn Visible="False">
<HeaderStyle Width="19px" />
</ExpandCollapseColumn>
<RowIndicatorColumn Visible="False">
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<%
-- <CommandItemTemplate>
<asp:ImageButton ID="imgNew" runat="server" ImageUrl="~/Image/ico_16_4.gif" />
</CommandItemTemplate>--
%>
</MasterTableView>
<
FilterMenu Skin="Vista" EnableTheming="True">
<
CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
</
FilterMenu>
</radG:RadGrid>
<input type="hidden" id="hidTxt" runat="server" />
</form>
protected
void Page_Load(object sender, EventArgs e)
{
}
protected void drpCodes_SelectedIndexChanged(object sender, EventArgs e)
{
string searchCode = "";
string codeTypeValue = ""; //Preferred code or Standard Code
RadComboBox cmbMedicalPrblm = null;
int countRadControls = RadGrid1.MasterTableView.Controls.Count;
for(int i = 0; i < countRadControls; i++)
{
int countChildControls = RadGrid1.MasterTableView.Controls[i].Controls.Count;
for (int j = 0; j < countChildControls; j++)
{
TextBox txtSearch = (TextBox)(RadGrid1.MasterTableView.Controls[i].Controls[j].FindControl("txtSearch"));
DropDownList drpCodes = (DropDownList)(RadGrid1.MasterTableView.Controls[i].Controls[j].FindControl("drpCodes"));
cmbMedicalPrblm = (
RadComboBox)(RadGrid1.MasterTableView.Controls[i].Controls[j].FindControl("radComboMedicalHx"));
if (txtSearch != null)
{
searchCode = txtSearch.Text;
}
if (drpCodes != null)
{
codeTypeValue = drpCodes.SelectedValue;
}
if (searchCode != "")
{
ButtonClick();
}
else
{
if (cmbMedicalPrblm != null)
{
if (codeTypeValue == "1")
{
string selectMedProblem = "select pk_id,code_value,Name,fk_group_id,risk,LITERATURE from M_ICD_CPT_CODE where fk_user_id = 374799 and MODULE_PHYS_PREF=1 and fk_code_type_id = 240000 and FK_Group_Id =245020 and row_status = 1 Order By Name";
DataTable dtMedProblem = new DataTable();
dtMedProblem = (
SqlHelper.ExecuteDataset(Utilities.GetConnectionString, CommandType.Text, selectMedProblem).Tables[0]);
cmbMedicalPrblm.DataSource = dtMedProblem;
cmbMedicalPrblm.DataValueField =
"pk_id";
cmbMedicalPrblm.DataTextField =
"Name";
cmbMedicalPrblm.DataBind();
dtMedProblem.Dispose();
}
else if (codeTypeValue == "2")
{
cmbMedicalPrblm.Items.Clear();
cmbMedicalPrblm.ClearSelection();
}
}
}
}
}
}
protected void txtSearch_TextChanged(object sender, EventArgs e)
{
if (hidTxt.Value == "1")
{
ButtonClick();
}
}
protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
dtMedicalHx =
new DataTable();
try
{
string selectMedHx = "select PK_ID, Name, DATE_ON_SET, DATE_RESOLVED, COMMENTS from m_icd_cpt_code left outer join m_medical_history on isnull(cast(m_icd_cpt_code.PK_ID as varchar),'') = m_medical_history.history_value where fk_visit_id = 1178745 and fk_user_id = 374799 and m_icd_cpt_code.row_status = 1";
dtMedicalHx =
new DataTable("MEDICAL_HISTORY");
dtMedicalHx = (
SqlHelper.ExecuteDataset(Utilities.GetConnectionString, CommandType.Text, selectMedHx).Tables[0]);
RadGrid1.DataSource = dtMedicalHx;
}
finally
{
}
}
protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
{
//Get the GridEditableItem of the RadGrid
GridEditableItem editedItem = e.Item as GridEditableItem;
//Get the primary key value using the DataKeyValue.
string pkId = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["PK_ID"].ToString();
//Access the controls from the edit form template and store the values in string variables.
string medicalProblemValue = (editedItem.FindControl("radComboMedicalHx") as RadComboBox).SelectedValue;
string medicalProblemText = (editedItem.FindControl("radComboMedicalHx") as RadComboBox).SelectedItem.Text;
RadComboBox cmbMedicalPrblm = (editedItem.FindControl("radComboMedicalHx") as RadComboBox);
string dateOnSet = (editedItem.FindControl("txtDateOnSet") as TextBox).Text;
string dateResolved = (editedItem.FindControl("txtDateResolved") as TextBox).Text;
string comments = (editedItem.FindControl("txtComments") as TextBox).Text;
string addPrefferedCode = (editedItem.FindControl("txtAddPreferredCode") as TextBox).Text;
bool chkPrefferedCode = (editedItem.FindControl("chkAddPreferredCode") as CheckBox).Checked;
try
{
if (chkPrefferedCode == true && addPrefferedCode != "")
{
#region
INSERT
long historyValue = -1;
#region
GET THE CODE VALUE
string selectCodeValue = "select code_value from M_ICD_CPT_CODE where pk_id = " + medicalProblemValue + " and row_status = 1";
string codeValue = Convert.ToString(SqlHelper.ExecuteScalar(Utilities.GetConnectionString, CommandType.Text, selectCodeValue));
#endregion
#region
INSERT INTO M_ICD_CPT_CODE TABLE THROUGH STORED PROCEDURE
Object pkIcdCpt = null;
pkIcdCpt = DLayer.
SqlHelper.ExecuteScalar(Utilities.GetConnectionString, "MEDICAL_HISTORY_INSERT", 245020, 374799, 240000, codeValue, addPrefferedCode, addPrefferedCode, addPrefferedCode, String.Empty, comments, String.Empty, String.Empty, 1, 1, 0);
if (Utilities.CheckNullState(pkIcdCpt))
{
historyValue = System.
Convert.ToInt64(pkIcdCpt);
}
#endregion
#region
BIND THE RADCOMBOBOX
string selectMedProblem = "select pk_id,code_value,Name,fk_group_id,risk,LITERATURE from M_ICD_CPT_CODE where fk_user_id = 374799 and MODULE_PHYS_PREF=1 and fk_code_type_id = 240000 and FK_Group_Id =245020 and row_status = 1 Order By Name";
DataTable dtMedProblem = new DataTable();
dtMedProblem = (
SqlHelper.ExecuteDataset(Utilities.GetConnectionString, CommandType.Text, selectMedProblem).Tables[0]);
cmbMedicalPrblm.DataSource = dtMedProblem;
cmbMedicalPrblm.DataValueField =
"pk_id";
cmbMedicalPrblm.DataTextField =
"Name";
cmbMedicalPrblm.DataBind();
dtMedProblem.Dispose();
#endregion
#endregion
}
else
{
string strUpdate = "update m_medical_history set fk_visit_id = 1178745, fk_vtd = 24000 ,history_value = '" + Convert.ToString(medicalProblemValue) + "',date_on_set = '" + dateOnSet.Replace("'", "''") + "',date_resolved = '" + dateResolved.Replace("'", "''") + "',comments = '" + comments.Replace("'", "''") + "' where history_value = '" + pkId.ToString() + "' and fk_visit_id = 1178745 and row_status = 1";
SqlHelper.ExecuteNonQuery(Utilities.GetConnectionString, CommandType.Text, strUpdate);
}
RadGrid1.DataBind();
}
catch (Exception ex)
{
RadGrid1.Controls.Add(
new LiteralControl("Unable to update Medical History. Reason: " + ex.Message));
e.Canceled =
true;
}
}
protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)
{
//Get the GridEditFormInsertItem of the RadGrid
GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item;
string pkID = insertedItem.OwnerTableView.DataKeyValues[insertedItem.ItemIndex]["PK_ID"].ToString();
//Access the textbox from the edit form template and store the values in string variables.
// string CustomerID = (insertedItem.FindControl("txtID") as TextBox).Text;
string medicalProblemValue = (insertedItem.FindControl("radComboMedicalHx") as RadComboBox).SelectedValue;
string medicalProblemText = (insertedItem.FindControl("radComboMedicalHx") as RadComboBox).SelectedItem.Text;
RadComboBox cmbMedicalPrblm = (insertedItem.FindControl("radComboMedicalHx") as RadComboBox);
string dateOnSet = (insertedItem.FindControl("txtDateOnSet") as TextBox).Text;
string dateResolved = (insertedItem.FindControl("txtDateResolved") as TextBox).Text;
string comments = (insertedItem.FindControl("txtComments") as TextBox).Text;
string drpValue = (insertedItem.FindControl("drpCodes") as DropDownList).SelectedValue;
string addPrefferedCode = (insertedItem.FindControl("txtAddPreferredCode") as TextBox).Text;
try
{
#region
INSERT
//int drpValue = Convert.ToInt32(drpCodes.SelectedValue);
long historyValue = -1;
if (drpValue == "2")
{
#region
GET THE CODE VALUE
string selectCodeValue = "select code_value from M_ICD_CPT_CODE where pk_id = " + medicalProblemValue + " and row_status = 1";
string codeValue = Convert.ToString(SqlHelper.ExecuteScalar(Utilities.GetConnectionString, CommandType.Text, selectCodeValue));
#endregion
#region
INSERT INTO M_ICD_CPT_CODE TABLE THROUGH STORED PROCEDURE
Object pkIcdCpt = null;
pkIcdCpt = DLayer.
SqlHelper.ExecuteScalar(Utilities.GetConnectionString, "MEDICAL_HISTORY_INSERT", 245020, 374799, 240000, codeValue, addPrefferedCode, addPrefferedCode, addPrefferedCode, String.Empty, comments, String.Empty, String.Empty, 1, 1, 0);
if (Utilities.CheckNullState(pkIcdCpt))
{
historyValue = System.
Convert.ToInt64(pkIcdCpt);
}
#endregion
#region
BIND THE RADCOMBOBOX
string selectMedProblem = "select pk_id,code_value,Name,fk_group_id,risk,LITERATURE from M_ICD_CPT_CODE where fk_user_id = 374799 and MODULE_PHYS_PREF=1 and fk_code_type_id = 240000 and FK_Group_Id =245020 and row_status = 1 Order By Name";
DataTable dtMedProblem = new DataTable();
dtMedProblem = (
SqlHelper.ExecuteDataset(Utilities.GetConnectionString, CommandType.Text, selectMedProblem).Tables[0]);
cmbMedicalPrblm.DataSource = dtMedProblem;
cmbMedicalPrblm.DataValueField =
"pk_id";
cmbMedicalPrblm.DataTextField =
"Name";
cmbMedicalPrblm.DataBind();
dtMedProblem.Dispose();
#endregion
}
if (drpValue == "1")
{
historyValue =
Convert.ToInt64(medicalProblemValue);
}
string insertMedHx = "insert into m_medical_history(fk_visit_id, fk_vtd,history_value,date_on_set,date_resolved,comments,row_status) values (1178745, 24000, " + historyValue + ", '" + dateOnSet.Replace("'", "''") + "', '" + dateResolved.Replace("'", "''") + "', '" + comments.Replace("'", "''") + "',1)";
SqlHelper.ExecuteNonQuery(Utilities.GetConnectionString, CommandType.Text, insertMedHx);
#endregion
}
catch (Exception ex)
{
RadGrid1.Controls.Add(
new LiteralControl("Unable to insert Customers. Reason: " + ex.Message));
e.Canceled =
true;
}
}
protected void RadGrid1_DataBound(object sender, EventArgs e)
{
RadComboBox cmbMedicalPrblm = null;
string codeTypeValue = "";
int countRadControls = RadGrid1.MasterTableView.Controls.Count;
for (int i = 0; i < countRadControls; i++)
{
int countChildControls = RadGrid1.MasterTableView.Controls[i].Controls.Count;
for (int j = 0; j < countChildControls; j++)
{
if (RadGrid1.MasterTableView.Controls[i].Controls[j].ToString() == "Telerik.Web.UI.GridEditFormItem")
{
DropDownList drpCodes = (DropDownList)(RadGrid1.MasterTableView.Controls[i].Controls[j].FindControl("drpCodes"));
cmbMedicalPrblm = (
RadComboBox)(this.RadGrid1.MasterTableView.Controls[i].Controls[j].FindControl("radComboMedicalHx"));
TextBox txtId = (TextBox)(RadGrid1.MasterTableView.Controls[i].Controls[j].FindControl("txtHidId"));
//TextBox txtHidId = (TextBox)(RadGrid1.MasterTableView.Controls[i].Controls[j].FindControl("txtID"));
if (drpCodes != null)
{
codeTypeValue = drpCodes.SelectedValue;
}
if (cmbMedicalPrblm != null)
{
//string value = cmbMedicalPrblm.Text;
if (codeTypeValue == "1")
{
string selectMedProblem = "select pk_id,code_value,Name,fk_group_id,risk,LITERATURE from M_ICD_CPT_CODE where fk_user_id = 374799 and MODULE_PHYS_PREF=1 and fk_code_type_id = 240000 and FK_Group_Id =245020 and row_status = 1 Order By Name";
DataTable dtMedProblem = new DataTable();
dtMedProblem = (
SqlHelper.ExecuteDataset(Utilities.GetConnectionString, CommandType.Text, selectMedProblem).Tables[0]);
cmbMedicalPrblm.DataSource = dtMedProblem;
cmbMedicalPrblm.DataValueField =
"pk_id";
cmbMedicalPrblm.DataTextField =
"Name";
cmbMedicalPrblm.DataBind();
cmbMedicalPrblm.SelectedValue = txtId.Text;
dtMedProblem.Dispose();
}
}
}
}
}
}
public void ButtonClick()
{
RadComboBox cmbMedicalPrblm = null;
string codeTypeValue = "";
string searchCode = "";
int countRadControls = RadGrid1.MasterTableView.Controls.Count;
for (int i = 0; i < countRadControls; i++)
{
int countChildControls = RadGrid1.MasterTableView.Controls[i].Controls.Count;
for (int j = 0; j < countChildControls; j++)
{
if (RadGrid1.MasterTableView.Controls[i].Controls[j].ToString() == "Telerik.Web.UI.GridEditFormItem")
{
DropDownList drpCodes = (DropDownList)(RadGrid1.MasterTableView.Controls[i].Controls[j].FindControl("drpCodes"));
cmbMedicalPrblm = (
RadComboBox)(this.RadGrid1.MasterTableView.Controls[i].Controls[j].FindControl("radComboMedicalHx"));
TextBox txtSearch = (TextBox)(RadGrid1.MasterTableView.Controls[i].Controls[j].FindControl("txtSearch"));
TextBox txtAddPreferredCode = (TextBox)(RadGrid1.MasterTableView.Controls[i].Controls[j].FindControl("txtAddPreferredCode"));
CheckBox chkAddPreferredCode = (CheckBox)(RadGrid1.MasterTableView.Controls[i].Controls[j].FindControl("chkAddPreferredCode"));
if (drpCodes != null)
{
codeTypeValue = drpCodes.SelectedValue;
}
if (txtSearch != null)
{
searchCode = txtSearch.Text;
}
if (cmbMedicalPrblm != null)
{
if (codeTypeValue == "1")
{
string selectMedProblems = "select pk_id,code_value,Name,fk_group_id,risk, LITERATURE from M_ICD_CPT_CODE where row_status = 1 and (( char255 like '" + "%" + searchCode.Replace("'", "''") + "%" + "' and char255 like '" + "%" + searchCode.Replace("'", "''").Replace("'", "''") + "%" + "' ) Or( char35 like '" + "%" + searchCode.Replace("'", "''") + "%" + "' and char35 like '" + "%" + searchCode.Replace("'", "''") + "%" + "' ) Or( code_value like '" + "%" + searchCode.Replace("'", "''") + "%" + "' and code_value like '" + "%" + searchCode.Replace("'", "''") + "%" + "' )) and fk_user_id = 374799 and MODULE_PHYS_PREF=1 and fk_code_type_id = 240000 and FK_Group_Id =245020 Order By Name";
DataTable dtMedProblem = new DataTable();
dtMedProblem = (
SqlHelper.ExecuteDataset(Utilities.GetConnectionString, CommandType.Text, selectMedProblems).Tables[0]);
cmbMedicalPrblm.DataSource = dtMedProblem;
cmbMedicalPrblm.DataValueField =
"pk_id";
cmbMedicalPrblm.DataTextField =
"Name";
cmbMedicalPrblm.DataBind();
dtMedProblem.Dispose();
//BindMedicalProblem(selectMedProblems);
chkAddPreferredCode.Visible =
false;
txtAddPreferredCode.Visible =
false;
}
if (codeTypeValue == "2")
{
string selectMedProblems = "select pk_id,code_value,Name,fk_group_id,risk, LITERATURE from M_ICD_CPT_CODE where row_status = 1 and (( char255 like '" + "%" + searchCode.Replace("'", "''") + "%" + "' ) Or( char35 like '" + "%" + searchCode.Replace("'", "''") + "%" + "' ) Or( code_value like '" + "%" + searchCode.Replace("'", "''") + "%" + "' )) and fk_user_id = 0 and fk_code_type_id = 240000 Order By Name";
chkAddPreferredCode.Visible =
true;
txtAddPreferredCode.Visible =
true;
DataTable dtMedProblem = new DataTable();
dtMedProblem = (
SqlHelper.ExecuteDataset(Utilities.GetConnectionString, CommandType.Text, selectMedProblems).Tables[0]);
cmbMedicalPrblm.DataSource = dtMedProblem;
cmbMedicalPrblm.DataValueField =
"pk_id";
cmbMedicalPrblm.DataTextField =
"Name";
cmbMedicalPrblm.DataBind();
dtMedProblem.Dispose();
}
}
}
}
}
}
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if ((e.Item.OwnerTableView.IsItemInserted))
{
GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item;
RadComboBox cmbMedicalPrblm = (RadComboBox)insertedItem["TempCol"].FindControl("radComboMedicalHx");
//RadComboBox cmbMedicalPrblm = (insertedItem.FindControl("radComboMedicalHx") as RadComboBox);
string selectMedProblem = "select pk_id,code_value,Name,fk_group_id,risk,LITERATURE from M_ICD_CPT_CODE where fk_user_id = 374799 and MODULE_PHYS_PREF=1 and fk_code_type_id = 240000 and FK_Group_Id =245020 and row_status = 1 Order By Name";
DataTable dtMedProblem = new DataTable();
dtMedProblem = (
SqlHelper.ExecuteDataset(Utilities.GetConnectionString, CommandType.Text, selectMedProblem).Tables[0]);
cmbMedicalPrblm.DataSource = dtMedProblem;
cmbMedicalPrblm.DataValueField =
"pk_id";
cmbMedicalPrblm.DataTextField =
"Name";
cmbMedicalPrblm.DataBind();
dtMedProblem.Dispose();
}
}
Here I m able to bind the RadCombo when I click on Edit link. But when I click on Add New Record then I the RadCombo does not bind.
So Please help Me
Dont bother about the query, give only suggestion that how i should bind the radcombo when i want to insert new record.
I suggest that you remove the lines which call the DataBind() method from your code and see if it makes any difference.
Additionally, find more information about insert/update/delete here
Regards,
Pavlina
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.