I am using IG Webtab in one of my project.I have two tabs say Tab1 and Tab2.I have dropdown inside this webtabs and Onselected index chnage event i am fetching dropdown's value to textbox.It works fine for tab1 but when i am selecting value from dropdown in Tab2.it is binding value to textbox of Tab1.
Hello Ankita,
Thank you for the code attachment!
I tried to create and compile a project with it, without success. Based on the code snippets alone, I could not say where the issue you are experiencing lies. In order to be able to further assist you, please add an isolated & runnable code sample I can actually debug.
This function is present on main design page as below
function tabSelectedIndexChanging(sender, eventArgs) { var tabIndex = sender.get_selectedIndex(); // current tab of the user document.getElementById('<%=hidTabIndex1.ClientID%>').value = tabIndex; }
Below is the complete page code behind page for repeater control page.
using System;using System.Collections.Generic;using System.Data;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;using CS.CRA.Common;
using CS.CRA.SessionManager;using CS.CRA.BusinessEntities;using Infragistics.WebUI.WebSpellChecker;using Infragistics.WebUI.WebHtmlEditor;using CS.CRA.CacheManager;using CS.CRA.Web.UICommon;
namespace CS.CRA.Web.UICommon.Controls{ public partial class QuestionRepeater : System.Web.UI.UserControl { public string WebSpellCheckerClientID { get; set; } public int metricId { get; set; } public int riskThemeId { get; set; } public string deskId { get; set; } public bool IsReadOnly { get; set; } public string sessionId { get; set; } public string checkedNA { get; set; } public string Comments { get; set; } public int riskThemeIdNA { get; set; } public int Period { get; set; } private int nCounter = 1;
public string selectedTab { get; set; } public string isDirty { get { return hfDirtyValue.Value; }
set { hfDirtyValue.Value = value; } }
protected void Page_Load(object sender, EventArgs e) { ISessionManager sessionManger = ((BasePage)this.Page).sessionManger; List<CommentsMaintenance> commentList = sessionManger.Get(CommentsMaintenanceSessionManager.COMMENT_LIST) as List<CommentsMaintenance>; // hfdddlcomnemtcontrolriskText.Value = Convert.ToString(ViewState["drpcomment"]); //if (hfddlcomment.Value != "") //{
ViewState["test"] = hfddlcomment.Value; Session["test"]= hfddlcomment.Value; hfdddlcomnemtcontrolriskText.Value = Convert.ToString(ViewState["drpcomment"]); //} if (sessionManger != null) { List<Question> questionList = sessionManger.Get(sessionId + "&" + QualitativeAssessmentSessionManager.QUESTION_LIST) as List<Question>; if (questionList != null) { //IEnumerable<Question> qList; //if (riskThemeIdNA != 0) //{ // qList = // questionList.Where(que => que.riskThemeId == this.riskThemeIdNA) // .Where(que => que.metricId == this.metricId); // checkedNA = "true"; //} //else //{
IEnumerable<Question> qList = questionList.Where(que => que.riskThemeId == this.riskThemeId) .Where(que => que.metricId == this.metricId); // checkedNA = "false"; //}
// string sessionID = string.Empty; //if (Request.QueryString["SessionID"] != null) //{ // sessionID = Convert.ToString(Request.QueryString["SessionID"]); // //q_a_SessionManager = new QualitativeAssessmentSessionManager(sessionID); //} //else // q_a_SessionManager = new QualitativeAssessmentSessionManager();
DataTable dt = sessionManger.Get(sessionId + "&" + QualitativeAssessmentSessionManager.RiskThemeNAList) as DataTable; bool markedNA = false; if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { if (Convert.ToInt32(dr["RiskThemeId"]) == this.riskThemeId) { checkedNA = "true"; Comments = dr["NAComments"].ToString(); markedNA = true; break;
} } }
if (markedNA) { checkedNA = "true"; } else { checkedNA = "false"; }
if (qList != null && qList.Count() > 0) { repQuestionnaire.DataSource = qList; repQuestionnaire.DataBind(); } else pnlNoData.Visible = true;
public void BindCommentsDropdown(List<CommentsMaintenance> CommentList, string responseName,DropDownList ddlcomment) { try { CommentsMaintenanceSessionManager CommentsMaintenanceSessionManager1 = new CommentsMaintenanceSessionManager(); // int RadioResponseID = Convert.ToInt32(rblResponses.SelectedValue); List<BusinessEntities.CommentsMaintenance> commentList = new List<BusinessEntities.CommentsMaintenance>(); if (CommentList != null) { if (CommentList.Count > 0) { ddlcomment.DataSource = CommentList.Where(c => c.MetricID == this.metricId && c.ResponseName == responseName); ddlcomment.DataTextField = "CommentText"; ddlcomment.DataValueField = "CommentID"; ddlcomment.DataBind(); ddlcomment.Items.Insert(0, new ListItem("-- Select --", "Select")); } } else { using (BusinessProcess.CommentsMaintenace bpcommentsmaintenance = new BusinessProcess.CommentsMaintenace()) { List<BusinessEntities.ResponseCommentsMaintenance> ResponseList = new List<BusinessEntities.ResponseCommentsMaintenance>(); List<BusinessEntities.RiskThemeMetric> metricList = new List<RiskThemeMetric>(); //List<BusinessEntities.AdminCommentList> commentList = new List<AdminCommentList>();
int result = bpcommentsmaintenance.GetCommentsList(Period, ref ResponseList, ref metricList, ref commentList); CommentsMaintenanceSessionManager1.Set(CommentsMaintenanceSessionManager.METRIC_LIST, metricList); if (commentList != null) { if (commentList.Count > 0) { ddlcomment.DataSource= commentList.Where(c => c.MetricID == this.metricId && c.ResponseName == responseName); ddlcomment.DataTextField = "CommentText"; ddlcomment.DataValueField = "CommentID"; ddlcomment.DataBind(); ddlcomment.Items.Insert(0, new ListItem("-- Select --", "Select")); ////drpComments.DataSource = commentList.Where(c => c.MetricID == this.metricId && c.ResponseName == responseName); //drpComments.DataTextField = "CommentText"; // drpComments.DataValueField = "CommentID"; // drpComments.DataBind();
} } } } } catch (Exception ex) {
}
} protected void repQuestionnaire_ItemDataBound_ItemCreated(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) {
DropDownList ddlcomment = e.Item.FindControl("ddlcomment") as DropDownList; ddlcomment.SelectedIndexChanged += ddlcomment_SelectedIndexChanged1; // (DropDownList)e.Item.FindControl("ddlcomment").OnSelectedIndexChanged += new EventHandler(ddlcomment_SelectedIndexChanged); // e.Item.FindControl("ddlcomment").SelectedIndexChanged += new EventHandler(TaskRadioButtonList_OnSelectedIndexChanged);
} } protected void repQuestionnaire_ItemDataBound(object sender, RepeaterItemEventArgs e) { // This event is raised for the header, the footer, separators, and items.
// Execute the following logic for Items and Alternating Items. if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { #region "Find Controls from item..."
int questionId = Convert.ToInt32(((HiddenField)e.Item.FindControl("hfQuestionId")).Value);
string showCommentsAlways = ((Question)e.Item.DataItem).showComments; string displayType = string.Empty; bool bShowCommentsBox = false;
Literal ltrQuestionNo = (Literal)e.Item.FindControl("ltrQuestionNo"); if (ltrQuestionNo != null) ltrQuestionNo.Text = Convert.ToString(nCounter++);
HtmlGenericControl divComments = ((HtmlGenericControl)e.Item.FindControl("divComments"));
RadioButtonList rblResponses = ((RadioButtonList)e.Item.FindControl("rblResponses"));
if (rblResponses != null) { rblResponses.Attributes.Add("onclick", "javascript:setDirtyFlag(true);"); } RequiredFieldValidator rfvComments = ((RequiredFieldValidator)e.Item.FindControl("rfvComments")); UserControl UC_txtComment = ((UserControl)e.Item.FindControl("txtComments")); TextBox txtComments = ((TextBox)UC_txtComment.FindControl("txtMessage")); if (txtComments != null) { txtComments.Attributes.Add("onblur", "javascript:validateMin10AndMax4000StringChar(this);"); } /* Image btnSpellCheck = ((Image)e.Item.FindControl("btnSpellCheck")); if (btnSpellCheck != null && txtComments != null) btnSpellCheck.Attributes.Add("onclick", "javascript:WebSpellingCheck('" + this.WebSpellCheckerClientID + "','" + txtComments.ClientID + "')"); */ HyperLink btnSpellCheck = ((HyperLink)e.Item.FindControl("lnkSpellCheck")); if (btnSpellCheck != null && txtComments != null) btnSpellCheck.Attributes.Add("onclick", "javascript:WebSpellingCheck('" + this.WebSpellCheckerClientID + "','" + txtComments.ClientID + "')");
#endregion
ISessionManager sessionManger = ((BasePage)this.Page).sessionManger; if (sessionManger != null) { List<Response> responseList = sessionManger.Get(sessionId + "&" + QualitativeAssessmentSessionManager.RESPONSE_LIST) as List<Response>; if (responseList != null) { foreach (Response response in responseList.Where(resp => resp.questionId == questionId)) { if (showCommentsAlways.Equals("Y")) // Check if comments text box has to be shown always for this question { if (bShowCommentsBox == false) divComments.Attributes.Add("style", "display:block;"); bShowCommentsBox = true; displayType = "block"; } else { if (bShowCommentsBox == false) divComments.Attributes.Add("style", "display:none;"); bShowCommentsBox = true; displayType = "none"; } if (response.commentsRequired.Equals("Y")) { //divComments.Attributes.Add("style", "display:block;"); displayType = "block"; if ((response.answeredId != 0)) { divComments.Attributes.Add("style", "display:block;"); bShowCommentsBox = true; } }
if (txtComments != null && !String.IsNullOrEmpty(response.comments)) // If comments exist for this response, show the comments box { divComments.Attributes.Add("style", "display:block;"); bShowCommentsBox = true; displayType = "block"; txtComments.Text = response.comments; }
ListItem item = new ListItem();
item.Text = response.responseText; item.Value = response.responseId.ToString(); //item.Selected = (response.answeredId != 0);
if (checkedNA != null && checkedNA.ToUpper().ToString() == "TRUE") { string sOptNA = item.Text.Remove(0, 1);
if (sOptNA.ToUpper().Contains(") NOT APPLICABLE")) { item.Selected = true; txtComments.Text = Comments; divComments.Attributes.Add("style", "display:block;"); displayType = "block"; bShowCommentsBox = true; } else { bool NAPresent = false; foreach ( Response response1 in responseList.Where(resp => resp.questionId == questionId)) {
string sOptNACheck = response1.responseText.Remove(0, 1); if (sOptNACheck.ToUpper().Contains(") NOT APPLICABLE")) { NAPresent = true; } } if (NAPresent == false) { item.Selected = (response.answeredId != 0); } }
} else { item.Selected = (response.answeredId != 0); }
item.Attributes.Add("onclick", "javascript:ShowHideComment('" + divComments.ClientID + "','" + rfvComments.ClientID + "','" + response.commentsRequired.Equals("Y") + "','" + displayType + "','" + rblResponses.ClientID + "');"); rblResponses.Items.Add(item); } } }
#region "Set control as read only for Submitted/Approved status..." if (IsReadOnly) { HtmlGenericControl divCommentsReadOnly = ((HtmlGenericControl)e.Item.FindControl("divCommentsReadOnly")); if (divCommentsReadOnly != null) divCommentsReadOnly.Attributes.Add("style", "display:block;");
Literal ltrCommentsReadOnly = ((Literal)e.Item.FindControl("ltrCommentsReadOnly")); if (ltrCommentsReadOnly != null && txtComments != null && !string.IsNullOrEmpty(txtComments.Text)) ltrCommentsReadOnly.Text = "<u>Comments:</u><br />" + txtComments.Text; if (divComments != null) divComments.Attributes.Add("style", "display:none;"); if (rblResponses != null) rblResponses.Enabled = false; } #endregion } }
public string SaveResponseList() { string metricId = string.Empty; ISessionManager sessionManger = ((BasePage)this.Page).sessionManger; List<Response> responseList = sessionManger.Get(sessionId + "&" + QualitativeAssessmentSessionManager.RESPONSE_LIST) as List<Response>; if (responseList != null) { foreach (RepeaterItem item in repQuestionnaire.Items) { #region "Find Controls from item..." int questionId = Convert.ToInt32(((HiddenField)item.FindControl("hfQuestionId")).Value); metricId = Convert.ToString(((HiddenField)item.FindControl("hfMetricId")).Value); RadioButtonList rblResponses = ((RadioButtonList)item.FindControl("rblResponses"));
if (!String.IsNullOrEmpty(rblResponses.SelectedValue)) { string comments = string.Empty; UserControl UC_txtComments = ((UserControl)item.FindControl("txtComments")); TextBox txtComments = ((TextBox)UC_txtComments.FindControl("txtMessage")); if (txtComments != null) comments = txtComments.Text.Trim();
//if (comments != "" && comments.Length > 4000) // throw new Exception("Error Comment-4000.$004: The length of comments is more than 4000. Please enter appropriate comment and try again"); //else if (comments != "" && comments.Length < 10) // throw new Exception("Error Comment-4000.$004: The length of comments is less than 10. Please enter appropriate comment and try again");
int responseId = Convert.ToInt32(rblResponses.SelectedValue);
Question currentQuestion = GetQuestion(questionId);
foreach (Response response in responseList.Where(resp => resp.questionId == questionId)) { if (response.responseId == responseId) { response.answeredId = responseId; if (response.commentsRequired.Equals("Y") || response.alwaysShowComments.Equals("Y")) response.comments = comments; if (currentQuestion.showComments.ToUpper().Equals("Y")) response.comments = comments; } else { response.answeredId = 0; if (response.commentsRequired.Equals("Y") || response.alwaysShowComments.Equals("Y")) response.comments = string.Empty; } } } #endregion } } return metricId; }
private Question GetQuestion(int questionID) { ISessionManager sessionManger = ((BasePage)this.Page).sessionManger; if (sessionManger != null) { List<Question> questionList = sessionManger.Get(sessionId + "&" + QualitativeAssessmentSessionManager.QUESTION_LIST) as List<Question>; if (questionList != null) { var result = questionList.Where(que => que.riskThemeId == this.riskThemeId && que.metricId == this.metricId && que.questionId == questionID); if (result != null && result.Count() > 0) return result.First(); } } return null; }
//protected void rblResponses_OnClick(object sender, EventArgs e) //{ // int RadioResponseID = Convert.ToInt32(rblResponses.SelectedValue); // CommentsMaintenanceSessionManager sessionMangercomments = new CommentsMaintenanceSessionManager(); // List<BusinessEntities.CommentsMaintenance> clist = sessionMangercomments.Get(CommentsMaintenanceSessionManager.COMMENT_LIST) as List<BusinessEntities.CommentsMaintenance>; // BindCommentsDropdown(clist); //} protected void rblResponses_changed(object sender, EventArgs e) { int responseID = 0; string responseName = ""; // int RadioResponseID = Convert.ToInt32(rblResponses.SelectedValue); foreach (RepeaterItem item in repQuestionnaire.Items) { // RadioButton rdbColour = item.FindControl("rdbColour") as RadioButton; RadioButtonList rblResponses = item.FindControl("rblResponses") as RadioButtonList; //DropDownList drpcomments = item.FindControl("drpComments") as DropDownList; //DropDownList ddlcomment=item // if (rblResponses.SelectedIndex != -1) { responseID = Convert.ToInt32(rblResponses.SelectedValue); CommentsMaintenanceSessionManager sessionMangercomments = new CommentsMaintenanceSessionManager(); List<BusinessEntities.CommentsMaintenance> clist = sessionMangercomments.Get(CommentsMaintenanceSessionManager.COMMENT_LIST) as List<BusinessEntities.CommentsMaintenance>; // BindCommentsDropdown(clist, responseName,); } //if (rblResponses.SelectedItem.Text == "Low Risk") //{
//}
protected void rblResponses_SelectedIndexChanged(object sender, EventArgs e) { int responseID = 0; string responseName = ""; string metricname = ""; string id = "0"; // string MetricTab // int RadioResponseID = Convert.ToInt32(rblResponses.SelectedValue); foreach (RepeaterItem item in repQuestionnaire.Items) { // RadioButton rdbColour = item.FindControl("rdbColour") as RadioButton; RadioButtonList rblResponses = item.FindControl("rblResponses") as RadioButtonList; // DropDownList drpcomments = item.FindControl("drpComments") as DropDownList; // DropDownList drpCommentText = item.FindControl("ddlcommenttext") as DropDownList; DropDownList ddlcomment = item.FindControl("ddlcomment") as DropDownList;
if (rblResponses.SelectedIndex != -1) { responseID = Convert.ToInt32(rblResponses.SelectedValue); string responseText = rblResponses.SelectedItem.Text.ToString(); responseName = responseText.Substring(responseText.LastIndexOf(')') + 1).TrimStart(); CommentsMaintenanceSessionManager CommentsMaintenanceSessionManager = new CommentsMaintenanceSessionManager(); List<BusinessEntities.CommentsMaintenance> clist = CommentsMaintenanceSessionManager.Get(CommentsMaintenanceSessionManager.COMMENT_LIST) as List<BusinessEntities.CommentsMaintenance>; ViewState["drpcomment"] = hfddlcomment.Value;
hfdddlcomnemtcontrolriskText.Value = Convert.ToString(ViewState["drpcomment"]);
hfdMetricID.Value = metricId.ToString();
//ViewState["drpcomment"] = hfddlcomment.Value;
//hfdddlcomnemtcontrolriskText.Value = Convert.ToString(ViewState["drpcomment"]); if (Session["hidTabIndex"].ToString() == "0") { metricname = "CIR"; } else if(Session["hidTabIndex"].ToString() == "1") { metricname = "CCR"; }
BindCommentsDropdown(clist, responseName, ddlcomment); List<BusinessEntities.RiskThemeMetric> metricList = new List<RiskThemeMetric>(); // List<BusinessEntities.CommentsMaintenance> metricList = CommentsMaintenanceSessionManager.Get(CommentsMaintenanceSessionManager.METRIC_LIST) as List<BusinessEntities.CommentsMaintenance>; if (metricList.Count == 0) { using (BusinessProcess.CommentsMaintenace bpcommentsmaintenance = new BusinessProcess.CommentsMaintenace()) { List<BusinessEntities.ResponseCommentsMaintenance> ResponseList = new List<BusinessEntities.ResponseCommentsMaintenance>();
List<BusinessEntities.CommentsMaintenance> commentList = new List<BusinessEntities.CommentsMaintenance>();
int result = bpcommentsmaintenance.GetCommentsList(Period, ref ResponseList, ref metricList, ref commentList); } } if (metricList != null && metricList.Count>0) { List<BusinessEntities.RiskThemeMetric> metricListSort = metricList.Where(m => m.MetricName == metricname).ToList(); id = metricListSort[0].ID.ToString(); } if (item.ClientID.Contains(id)) { if (hfdddlcomnemtcontrolriskText.Value != "") { ddlcomment_SelectedIndexChanged1( sender, e); } } // ddlcomment_SelectedIndexChanged1(sender, e); } }
//else if (ddlcomment.Items.Count >0 && ddlcomment.SelectedItem != null) // { // UserControl UC_txtComments = ((UserControl)item.FindControl("txtComments")); // TextBox txtComments = ((TextBox)UC_txtComments.FindControl("txtMessage")); // if (txtComments != null) // txtComments.Text = ddlcomment.SelectedItem.Text.ToString(); // } //if (rblResponses.SelectedItem.Text == "Low Risk") //{
// CommentsMaintenanceSessionManager sessionMangercomments = new CommentsMaintenanceSessionManager(); // List<BusinessEntities.CommentsMaintenance> clist = sessionMangercomments.Get(CommentsMaintenanceSessionManager.COMMENT_LIST) as List<BusinessEntities.CommentsMaintenance>; // BindCommentsDropdown(clist); }
//protected void drpCommentsSelect(object sender, EventArgs e) //{
// foreach (RepeaterItem item in repQuestionnaire.Items) // { // // if (!String.IsNullOrEmpty(drpComments.SelectedValue)) // { // string comments = string.Empty; // UserControl UC_txtComments = ((UserControl)item.FindControl("txtComments")); // TextBox txtComments = ((TextBox)UC_txtComments.FindControl("txtMessage")); // if (txtComments != null) // // txtComments.Text = drpComments.SelectedItem.Text;
// //if (comments != "" && comments.Length > 4000) // // throw new Exception("Error Comment-4000.$004: The length of comments is more than 4000. Please enter appropriate comment and try again"); // //else if (comments != "" && comments.Length < 10) // // throw new Exception("Error Comment-4000.$004: The length of comments is less than 10. Please enter appropriate comment and try again");
// //int responseId = Convert.ToInt32(rblResponses.SelectedValue);
// } // } //}
//protected void ddlcommenttext_SelectedIndexChanged(object sender, EventArgs e) //{ // //if (!String.IsNullOrEmpty(ddlcommenttext.SelectedValue)) // //{ // // string comments = string.Empty;
// //} //}
//protected void ddlcomment_SelectedIndexChanged(object sender, EventArgs e) //{
protected void repQuestionnaire_ItemCreated(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) {
} }
protected void ddlcomment_SelectedIndexChanged1(object sender, EventArgs e) {
try {
foreach (RepeaterItem item in repQuestionnaire.Items) { DropDownList ddlcomment = item.FindControl("ddlcomment") as DropDownList;
if (!String.IsNullOrEmpty(ddlcomment.SelectedValue)) { //if(item.ClientID.Contains()) string comments = string.Empty; UserControl UC_txtComments = ((UserControl)item.FindControl("txtComments")); TextBox txtComments = ((TextBox)UC_txtComments.FindControl("txtMessage")); if (txtComments != null) txtComments.Text = hfddlcommentText.Value; if (hfddlcomment.Value != null || hfddlcomment.Value != "") { if(hfddlcomment.Value != "Select") ddlcomment.SelectedIndex = Convert.ToInt32(hfddlcomment.Value); // ddlcomment.SelectedItem.Text = hfddlcommentText.Value; } else { ddlcomment.SelectedIndex = 0; } //if (comments != "" && comments.Length > 4000) // throw new Exception("Error Comment-4000.$004: The length of comments is more than 4000. Please enter appropriate comment and try again"); //else if (comments != "" && comments.Length < 10) // throw new Exception("Error Comment-4000.$004: The length of comments is less than 10. Please enter appropriate comment and try again");
//int responseId = Convert.ToInt32(rblResponses.SelectedValue);
} } } catch (Exception ex) {
} } } }
Thank you for the code snippets!
I do not see the tabSelectedIndexChanging handler in code behind as well as the WebTab ContentTabItem setup though. As far as I understand from the initial asking, there should be at least two tabs in the WebTab.
In order to be able to further assist you, please add an isolated&runnable code sample I can actually debug, containing the whole relevant markup and behind code for the WebTab /WebDropDowns/Inputs?
Thanks you in advance!
On main page i have tab as below
<ig:WebTab ID="tabMatric" runat="server" Height="550px" EnableViewState="true"> <ClientEvents Loaded="tabMatric_Loaded" SelectedIndexChanging="tabSelectedIndexChanging" /> </ig:WebTab>
On Repeater control I have below code
<asp:Repeater ID="repQuestionnaire" runat="server" EnableViewState="True" OnItemDataBound="repQuestionnaire_ItemDataBound" OnItemCreated="repQuestionnaire_ItemCreated"> <ItemTemplate> <table cellpadding="3" width="98%"> <tr>
<td width="100%"> <span class="QuestionText"> <asp:RadioButtonList ID="rblResponses" runat="server" RepeatColumns="1" AutoPostBack="true" OnSelectedIndexChanged="rblResponses_SelectedIndexChanged" EnableViewState="true" /> <asp:HiddenField ID="hfresponses" runat="server" /> <div> <asp:DropDownList ID="ddlcomment" AutoPostBack="true" runat="server" Enabled="true" EnableViewState="true" OnChange="GetSelectedTextValue(this)" OnSelectedIndexChanged="ddlcomment_SelectedIndexChanged1" ></asp:DropDownList> </div> <div id="divComments" runat="server" style="display: none"> <table style="width: 95%" cellpadding="1"> <tr> <td class="print" align="right"> <asp:HyperLink ID="lnkSpellCheck" runat="server" Text="Check Spelling" ></asp:HyperLink><br /> </td> </tr> <tr> <td> <%-- <asp:TextBox ID="txtComments" runat="server" TextMode="MultiLine" Width="100%" Height="90px" />--%> <uc4:uc_MultiLineLimitedCharacter ID="txtComments" runat="server" Width="100%" Height="100px" MaxLength="4000" /> </td>
</tr>
</table>
</Itemtemplate>
</asp:repeater>
Code behind repeater
protected void Page_Load(object sender, EventArgs e) {
if (qList != null && qList.Count() > 0) { repQuestionnaire.DataSource = qList; repQuestionnaire.DataBind(); }
protected void rblResponses_SelectedIndexChanged(object sender, EventArgs e) { int responseID = 0; string responseName = ""; // string MetricTab // int RadioResponseID = Convert.ToInt32(rblResponses.SelectedValue); foreach (RepeaterItem item in repQuestionnaire.Items) { // RadioButton rdbColour = item.FindControl("rdbColour") as RadioButton; RadioButtonList rblResponses = item.FindControl("rblResponses") as RadioButtonList; // DropDownList drpcomments = item.FindControl("drpComments") as DropDownList; // DropDownList drpCommentText = item.FindControl("ddlcommenttext") as DropDownList; DropDownList ddlcomment = item.FindControl("ddlcomment") as DropDownList;
if (rblResponses.SelectedIndex != -1) { responseID = Convert.ToInt32(rblResponses.SelectedValue); string responseText = rblResponses.SelectedItem.Text.ToString(); responseName = responseText.Substring(responseText.LastIndexOf(')') + 1).TrimStart(); CommentsMaintenanceSessionManager sessionMangercomments = new CommentsMaintenanceSessionManager(); List<BusinessEntities.CommentsMaintenance> clist = sessionMangercomments.Get(CommentsMaintenanceSessionManager.COMMENT_LIST) as List<BusinessEntities.CommentsMaintenance>;
BindCommentsDropdown(clist, responseName, ddlcomment); if ( hfddlcomment.Value != "") { ddlcomment_SelectedIndexChanged1( sender, e); } // ddlcomment_SelectedIndexChanged1(sender, e); } }
public void BindCommentsDropdown(List<CommentsMaintenance> CommentList, string responseName,DropDownList ddlcomment) { try { // int RadioResponseID = Convert.ToInt32(rblResponses.SelectedValue); List<BusinessEntities.CommentsMaintenance> commentList = new List<BusinessEntities.CommentsMaintenance>(); if (CommentList != null) { if (CommentList.Count > 0) { ddlcomment.DataSource = CommentList.Where(c => c.MetricID == this.metricId && c.ResponseName == responseName); ddlcomment.DataTextField = "CommentText"; ddlcomment.DataValueField = "CommentID"; ddlcomment.DataBind(); ddlcomment.Items.Insert(0, new ListItem("-- Select --", "Select")); } } else { using (BusinessProcess.CommentsMaintenace bpcommentsmaintenance = new BusinessProcess.CommentsMaintenace()) { List<BusinessEntities.ResponseCommentsMaintenance> ResponseList = new List<BusinessEntities.ResponseCommentsMaintenance>(); List<BusinessEntities.RiskThemeMetric> metricList = new List<RiskThemeMetric>(); //List<BusinessEntities.AdminCommentList> commentList = new List<AdminCommentList>();
int result = bpcommentsmaintenance.GetCommentsList(Period, ref ResponseList, ref metricList, ref commentList); if (commentList != null) { if (commentList.Count > 0) { ddlcomment.DataSource= commentList.Where(c => c.MetricID == this.metricId && c.ResponseName == responseName); ddlcomment.DataTextField = "CommentText"; ddlcomment.DataValueField = "CommentID"; ddlcomment.DataBind(); ddlcomment.Items.Insert(0, new ListItem("-- Select --", "Select")); ////drpComments.DataSource = commentList.Where(c => c.MetricID == this.metricId && c.ResponseName == responseName); //drpComments.DataTextField = "CommentText"; // drpComments.DataValueField = "CommentID"; // drpComments.DataBind();
protected void repQuestionnaire_ItemDataBound(object sender, RepeaterItemEventArgs e) { // This event is raised for the header, the footer, separators, and items.
if (!String.IsNullOrEmpty(ddlcomment.SelectedValue)) { string comments = string.Empty; UserControl UC_txtComments = ((UserControl)item.FindControl("txtComments")); TextBox txtComments = ((TextBox)UC_txtComments.FindControl("txtMessage")); if (txtComments != null) txtComments.Text = hfddlcommentText.Value; if (hfddlcomment.Value != null || hfddlcomment.Value != "") { if(hfddlcomment.Value != "Select") ddlcomment.SelectedIndex = Convert.ToInt32(hfddlcomment.Value); // ddlcomment.SelectedItem.Text = hfddlcommentText.Value; } else { ddlcomment.SelectedIndex = 0; } //if (comments != "" && comments.Length > 4000) // throw new Exception("Error Comment-4000.$004: The length of comments is more than 4000. Please enter appropriate comment and try again"); //else if (comments != "" && comments.Length < 10) // throw new Exception("Error Comment-4000.$004: The length of comments is less than 10. Please enter appropriate comment and try again");
Can you please add a runnable code sample so I can see how the binding is set and test the actual code locally?
Thanks in advance!