.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

GridView.RowCommand Event:-

Posted By: bhanu     Posted Date: November 24, 2010    Points:2   Category :ASP.Net
<asp:LinkButton ID="lnkproductname" runat="server" CommandArgument='<%#Eval("defaultmsg")%>'
CommandName="selectproduct" Text='<%#Eval("defaultmsg") %>'> </asp:LinkButton>

In griview row command iam eriting as:
--------------------------------------------------


protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "selectproduct")
{
txtmsg.Text = Convert.ToString(e.CommandArgument.ToString());
}

}

the value is not displaying in txtmsg textbox..please help me


Responses
Author: Sajid P K             
Posted Date: November 24, 2010     Points: 5   

bhanu,

Can you please post full page aspx code ?

or if ur using Update panel.. Please check both textbox and grid are inside the update panel.


Regards,
Sajid P K

Author: bhanu             
Posted Date: November 24, 2010     Points: 5   

<%@ Page Language="C#" MasterPageFile="~/DataEntry/UserMaster.master" AutoEventWireup="true"
CodeFile="sendsms.aspx.cs" Inherits="DataEntry_sendsms" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContentPanel" runat="Server">

<script language="javascript" type="text/javascript">


function getkeyup() {


var m = "140";
var len = document.getElementById("<%=txtmsg.ClientID%>").value.length;
var str = document.getElementById("<%=txtmsg.ClientID%>").value;

if (len <= m) {
document.getElementById("<%=txtremchars.ClientID%>").value = m - len;
}

else {
document.getElementById("<%=txtmsg.ClientID%>").value = str.substr(0, str.length - 1);
}

}
function test(id) {


document.getElementById("<%=txtmsg.ClientID%>").value = id;
var m = "140";
var len = document.getElementById("<%=txtmsg.ClientID%>").value.length;
var str = document.getElementById("<%=txtmsg.ClientID%>").value;
if (len <= m) {
document.getElementById("<%=txtremchars.ClientID%>").value = m - len;
}
else {
document.getElementById("<%=txtmsg.ClientID%>").value = str.substr(0, str.length - 1);
}


//document.getElementById("txt_send_sms").value = document.getElementById(msgid).innerHTML.replace(/<br>/g, '\n').replace(/<BR>/g, '\n');
return false;

}

function mobchar() {
var mobileno = document.getElementById("<%=txtmobile.ClientID %>").value;
var ValidChars = ",0123456789";
var IsNumber = true;
var Char, fmob = "";
for (i = 0; i < mobileno.length && IsNumber == true; i++) {
Char = mobileno.charAt(i);
if (ValidChars.indexOf(Char) == -1) {
//alert("hai");
}
else {
if (mobileno.length > 1) {
fmob = fmob + Char;
}
}
}


if (isNaN(mobileno)) {
document.getElementById("<%=txtmobile.ClientID %>").value = fmob;
return false;
}
if (mobileno.search(/[^0-9,\-()+]/g) != -1) {
document.getElementById("<%=txtmobile.ClientID %>").value = fmob;
return false;
}
}


function sendsmsvalidate() {

if (document.getElementById("<%=txtmobile.ClientID%>").value == "") {
alert("Mobile Number should not be blank");
document.getElementById("<%=txtmobile.ClientID %>").focus();
return false;
}
var no = /^\d{10}$/;
var mobileno = document.getElementById("<%=txtmobile.ClientID %>").value;
var matchArrays = mobileno.match(no);
if (matchArrays == null) {
alert("mobile number contains Only Numerics and minimum 10 digits.");
document.getElementById("<%=txtmobile.ClientID %>").focus();
return false;
}
if (mobileno.charAt(0) < "7") {
alert("Mobile number should start with 9 or 8 or 7");
document.getElementById("<%=txtmobile.ClientID %>").focus();
return false;
}
var mobno = document.getElementById("<%=txtmobile.ClientID %>").value;
var mob_arr = mobno.split(",");
var part_num = 0;
while (part_num < mob_arr.length) {
var ni = part_num + 1;
var chk_mob = mob_arr[part_num];
if (chk_mob.length < 10) {
alert(" " + chk_mob + " mobile contains invalid Mobile Number Length");
document.getElementById("<%=txtmobile.ClientID %>").focus();
return false;
}
if (chk_mob.charAt(0) < 7) {
alert(" " + chk_mob + " is invalid Mobile Number");
document.getElementById("<%=txtmobile.ClientID %>").focus();
return false;
}
part_num += 1;
}

if (document.getElementById("<%=txtmsg.ClientID%>").value == "") {
alert("Message should not be blank");
document.getElementById("<%=txtmsg.ClientID %>").focus();
return false;
}


}
</script>

<div>
<fieldset style="background-color: #FEF0C9">
<legend>
<div style="width: 300px; float: left; padding-right: 20px;">
<span class="h_txt16_2"><font color="red">Send Sms</font></span>
<table>
<tr>
<td>
<asp:Label ID="Lblmobilenumber" runat="server" Text="Mobile Number"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="txtmobile" runat="server" Width="239px" TextMode="MultiLine"></asp:TextBox>
Enter Mobile numbers seperated by commas.
</td>
</tr>
<tr>
<td>
<asp:Label ID="Lblmsg" runat="server" Text="Message:"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="txtmsg" runat="server" TextMode="MultiLine" Height="91px" Width="239px"
MaxLength="140"></asp:TextBox>
</td>
</tr>
<tr>
<td>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Characters Remaining:
<asp:TextBox ID="txtremchars" runat="server" Style="width: 100px;" ReadOnly="True"
Text="140"></asp:TextBox>
&nbsp;
</td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;<asp:Button ID="btnsend" runat="server" Text="send" CausesValidation="false"
OnClientClick="return sendsmsvalidate()" OnClick="btnsend_Click" Width="73px" />
</td>
</tr>
</table>
</div>
</legend>
<div style="padding-bottom: 25px; width: 300px; float: left;">
<div class="regist_field">
<p class="reg_right_fiel_p" style="color: Red;">
To use Default messages , select category below
</p>
</div>
<div class="regist_field" style="padding-bottom: 25px;">
<p class="reg_left_fiel_p">
Category :</p>
<p class="reg_right_fiel_p">
<asp:DropDownList ID="ddlcategory" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlcategory_SelectedIndexChanged">
</asp:DropDownList>
</p>
</div>
<div class="regist_field" style="padding-bottom: 25px;">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" GridLines="Horizontal" AutoGenerateColumns="False"
PageSize="3" EmptyDataText="No Companies Found" BorderWidth="1px" AllowPaging="True"
OnPageIndexChanging="GridView1_PageIndexChanging" ShowHeader="False" Width="100%"
OnRowCommand="GridView1_RowCommand">
<RowStyle BorderStyle="None" BorderWidth="1"></RowStyle>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<%-- <asp:LinkButton ID="LinkButton2" runat="server" Style="padding: 5px 5px 5px 5px;
float: left; text-decoration: none;" Text='<%#Eval("defaultmsg")%>' OnClick="LinkButton2_Click">
</asp:LinkButton>--%>
<%--<asp:LinkButton ID="LinkButton1" runat="server" Style="padding: 5px 5px 5px 5px;
float: left;" Text='<%#Eval("defaultmsg")%>' OnClientClick='<%# DataBinder.Eval(Container.DataItem,"defaultmsg","return test(\"{0}\")")%>'>


</asp:LinkButton>--%>
<asp:LinkButton ID="LinkButton1" runat="server" Style="padding: 5px 5px 5px 5px;
float: left;" Text='<%#Eval("defaultmsg")%>' OnClientClick='<%# "return test(\"" + Eval("defaultmsg") + "\")" %>'>


</asp:LinkButton>
<%--
<asp:LinkButton ID="lnkproductname" runat="server" CommandArgument='<%#Eval("defaultmsg")%>'
Text='<%#Eval("defaultmsg") %>'> </asp:LinkButton>--%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlcategory" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
</div>
</legend>
</fieldset>
</div>
</asp:Content>


Author: Sajid P K             
Posted Date: November 24, 2010     Points: 5   

Hi,

Put txtmsg text box inside the same UpdatePanel gridview reside.



Regards,
Sajid P K



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend