Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Guys
I want to display Client name into Textbox control. The data is coming from database. But problem i am facing is that whenever i edit the that client name
For example Suppose default name is "Rajesh" but if i edit it like " < rajesh >", It generates an exception error "There is no Row At Position 0". Now my scenario is that i want to display the client name inside textbox which is editable. So how can i perform this task. Please help. Thanks






Ok here is my code :



XML
<%@ Page Title="" Language="C#" MasterPageFile="~/include/master/home_page.master" AutoEventWireup="true" CodeFile="message.aspx.cs" Inherits="admin_smsmarketing_message" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderHead" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderBody" Runat="Server">
  <script type="text/javascript">
    function OpenPage() {
      var sValue = document.getElementById('<%=txtMessageText.ClientID %>').value;
      if (sValue == "") {
        alert("Please Type Your Message.");
      }
      else {
        var sUrl = "/admin/smsmarketing/sendmessage.aspx";
        window.open(sUrl, '_top', '', '');
      }
    }

    $(document).ready(function () {
      CharCount();
      $('#<%=txtMessageText.ClientID %>').keyup(function (e) {
        CharCount();
      });

      function CharCount() {
        var tbLength = $('#<%=txtMessageText.ClientID %>').val().length;
        $('#<%=lblCharCount.ClientID %>').text("Total Character: " + tbLength);
      }
    });
  </script>
  <div id="mid_undr_wrapp">
    <div style="height: 23px;">
    </div>
    <div id="socialpage_tab_wrapp">
      <div id="Progressbar_wrapp">
        <ul id="progress">
          <li class="blue"><a href="/admin/">Dashboard &rarr; </a></li>
          <li class="blue"><a href="/admin/smsmarketing/sms_schedule_list.aspx">SMS &rarr;</a></li>
          <li class="orange disable-link"><a href="#">Message Body &rarr;</a></li>
          <li> <a class="disable-link" href="#">Contact List &rarr;</a></li>
          <li><a class="disable-link" href="#">Schedule  &rarr;</a></li>
          <li><a class="disable-link" href="#">Confirmation </a></li>
        </ul>
      </div>
      <div id="pge_heading_txt">
        Message Body
      </div>
      <div style="height: 28px;">
      </div>
      <div style="width:80%; margin:0 auto;">
        <div>
          <div style="width: 30%; float: left;">
            <b class="field-caption">SMS Content</b>
            <br />
            <asp:Label ID="lblCharCount" CssClass="lblmsg" runat="server"  />
            <br />
            <div class="scheduleemailnote">
              One message can contain upto 160 characters otherwise multiple messages will be
              sent.
            </div>
          </div>
          <div style="width: 70%; float: left;">
            <div>
              <asp:TextBox ID="txtMessageText" runat="server" TextMode="MultiLine" Height="120px"
                Width="400px"></asp:TextBox>
            </div>
          <asp:RequiredFieldValidator ID="rfvMessage" ControlToValidate="txtMessageText" Display="None" runat="server" ErrorMessage="Please Type Your Message." />
          <asp:ValidationSummary ID="vs" ShowMessageBox="true" ShowSummary="false" runat="server" />
          </div>
        </div>
        <div style="height: 17px;">
        </div>
        <div style="text-align: left;">
          <asp:ImageButton ID="btnBack" runat="server" ImageUrl="~/images/back.png" CausesValidation="false" OnClick="btnBack_Click" />
          <asp:ImageButton ID="imgContinue" runat="server" ImageUrl="/images/continue.png" OnClick="imgContinue_Click" />
          <asp:ImageButton ID="btnSave" runat="server" ImageUrl="/images/save.png" OnClick="btnSave_Click" />
          <asp:ImageButton ID="btnCancel" runat="server" ImageUrl="/images/cancel.png" CausesValidation="false" OnClick="btnCancel_Click" />
        </div>
      </div>
      <div class="clear">
      </div>
      <div style="height: 143px;">
      </div>
    </div>
  </div>
</asp:Content>






CS:



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using socialmediasms;

public partial class admin_smsmarketing_message : System.Web.UI.Page
{
private int m_iClientId = 0;
private int m_iScheduleId = 0;
private int m_iCampaignTypeId = 0;
private string m_sScheduleName = string.Empty;
private string m_sMessageText = string.Empty;
private bool m_bUpdate = false;
protected void Page_Load(object sender, EventArgs e)
{
m_iClientId = Sessioncl.GetLoggedInClientId();
m_iCampaignTypeId = ClientCampaigncl.GetCampaignType(ClientCampaigncl.eCampaignType.SmsMarketing);
if (Request.QueryString["i"] != null)
{
m_bUpdate = true;
m_iScheduleId = Numericcl.GetIntValue(Request.QueryString["i"]);
}
else
{
m_iScheduleId = Numericcl.GetIntValue(Sessioncl.GetSessionScheduleId());
}
if (!IsPostBack)
{
this.PopulateDetails();
this.ManageButton();
ViewState["Referrer"] = Stringcl.GetValue(Request.UrlReferrer);
}
}

protected void imgContinue_Click(object sender, ImageClickEventArgs e)
{
EmailSchedulecl oEmailSchedulecl = new EmailSchedulecl(m_iClientId, m_iScheduleId);
m_iScheduleId = oEmailSchedulecl.UpdateSchedule(m_iCampaignTypeId, m_iScheduleId, oEmailSchedulecl.ScheduleStatusTypeId, oEmailSchedulecl.ScheduleName, Stringcl.GetValue(txtMessageText.Text));
Response.Redirect("/admin/smsmarketing/sms_user_list.aspx");
}

protected void btnBack_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("/admin/smsmarketing/sms_schedule_list.aspx");
}

protected void btnSave_Click(object sender, ImageClickEventArgs e)
{
EmailSchedulecl oEmailSchedulecl = new EmailSchedulecl(m_iClientId, m_iScheduleId);
m_iScheduleId = oEmailSchedulecl.UpdateSchedule(m_iCampaignTypeId, m_iScheduleId, oEmailSchedulecl.ScheduleStatusTypeId, oEmailSchedulecl.ScheduleName, Stringcl.GetValue(txtMessageText.Text));
if (Stringcl.GetValue(ViewState["Referrer"]) != string.Empty)
{
Response.Redirect(Stringcl.GetValue(ViewState["Referrer"]));
}
else
{
Response.Redirect("/admin/smsmarketing/");
}
}

protected void btnCancel_Click(object sender, ImageClickEventArgs e)
{
if (Stringcl.GetValue(ViewState["Referrer"]) != string.Empty)
{
Response.Redirect(Stringcl.GetValue(ViewState["Referrer"]));
}
else
{
Response.Redirect("/admin/smsmarketing/");
}
}

private void PopulateDetails()
{
Clientcl oClientcl = new Clientcl(m_iClientId);
if (m_iScheduleId > 0)
{
try
{
EmailSchedulecl oEmailSchedulecl = new EmailSchedulecl(m_iClientId, m_iScheduleId);
string client_details = oClientcl.FirstName + " " + oClientcl.LastName;
txtMessageText.Text = "From :" + client_details;
txtMessageText.Text += "\n\n" + "For unsubscribing contact";
}
catch (Exception ex)
{
Errorcl.HandleException(ex, true);
}
}
}

private void ManageButton()
{
if (m_bUpdate)
{
imgContinue.Visible = false;
btnBack.Visible = false;
btnSave.Visible = true;
btnCancel.Visible = true;
}
else
{
imgContinue.Visible = true;
btnBack.Visible = true;
btnSave.Visible = false;
btnCancel.Visible = false;
}
}
}
Posted
Updated 27-Jul-14 18:17pm
v3
Comments
Sandeep Singh Shekhawat 26-Jul-14 8:07am    
Could you please post your code here ?
Abhijit Ghosh (Subho) 26-Jul-14 12:04pm    
Please improve your question. Show us your code and provide a little more detail.

1 solution

"There is no Row At Position 0"
this means your datatable is nill. check your query again..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900