Click here to Skip to main content
12,394,788 members (67,129 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
I have a gridview and i want to send sms to user on button click event and save some data into database (i am using sql server) . But my problem is that when first row complete update in gridviw show status sent(in UI) while process will be continue

my gridView


<asp:GridView ID="grdvdiffrentMsg" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Mobile No">
<ItemTemplate>
    <asp:Label ID="lblMobileNo" runat="server" Text='<%# Eval("mobileNo") %>' />
    <asp:HiddenField ID="hfStudId" runat="server" Value='<%# Eval("StudId") %>' />


my button click event

sendSMS

protected void btnSendMsg_Click(object sender, EventArgs e)
{
    int sms=0;
    if (Session["SMS"] != null)
    {
        sms = Convert.ToInt32(Session["SMS"].ToString());
    }
    if (sms > 0)
    {
    //foreach (GridViewRow gvr in grdvdiffrentMsg.Rows)
    // {
    //     HiddenField stuId = (HiddenField)gvr.FindControl("hfStudId");
    //     Label lblMobileNo = (Label)gvr.FindControl("lblMobileNo");
    //     Label lblMsg = (Label)gvr.FindControl("lblMessage");
         //if (lblMobileNo.Text != string.Empty && lblMsg.Text != string.Empty)
         //{
            dt=(DataTable)ViewState["MultiSMS"];
             objcommonsms.sendSMS(ddlMsgType.SelectedItem.Text, Session["SenderId"].ToString(),Session["UserId"].ToString(),sms,dt);
         //}

     //}
    }
 
}


sendSMS function is used for save data in database


please show me code with example


thanks in advance
Posted 9-May-13 1:54am
Updated 9-May-13 1:55am
v2
Comments
pradiprenushe 14-Aug-13 4:20am
   
This cant be done in single call. You can use hidden button in each row with some command name.
Through javascript call each row button click asynchrounously.
pradiprenushe 14-Aug-13 4:22am
   
You have to
No of sms send = no of calls to server (asynchronously)
Use Page method to call server side functionality

Do following steps
1.loop through gridview
http://patelpc.blogspot.in/2011/12/loop-through-gridview-row-in-javascript.html
2. Use page method for send mail
http://aspsnippets.com/Articles/Call-ASPNet-Page-Method-using-jQuery-AJAX-Example.aspx

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

i've used it here is the code use it as per your requirement

protected void Button1_Click(object sender, EventArgs e)
    {
 
       
for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            TextBox tb1 = GridView1.Rows["row index"].FindControl("Textbox1") as TextBox;
            UpdateFunction(tb1.Text);
        }
 
}
  Permalink  
Comments
ashok luhach 9-May-13 23:01pm
   
UpdateFunction(tb1.Text) sir how this function update gridview column
Bikash Prakash Dash 10-May-13 0:43am
   
My friend this is a sample function i'm giving example, use your function for update instead of this.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 9 May 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100