Click here to Skip to main content
Rate this: bad
good
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") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Meassage">
<ItemTemplate>
    <asp:Label ID="lblMessage" runat="server" Text='<%# Eval("Message") %>'></asp:Label>
    </ItemTemplate>
</asp:TemplateField>
 
</Columns>
    </asp:GridView>
    <p>
        <asp:Button ID="btnSendMsg" runat="server" Text="Send"
            onclick="btnSendMsg_Click" />
    </p>
 

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 2:54am
Edited 9-May-13 2:55am
v2
Comments
pradiprenushe at 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 at 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 at 9-May-13 23:01pm
   
UpdateFunction(tb1.Text) sir how this function update gridview column
Bikash Prakash Dash at 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
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,127
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 9 May 2013
Copyright © CodeProject, 1999-2014
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