Click here to Skip to main content
13,046,474 members (71,112 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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">
<asp:TemplateField HeaderText="Mobile No">
    <asp:Label ID="lblMobileNo" runat="server" Text='<%# Eval("mobileNo") %>' />
    <asp:HiddenField ID="hfStudId" runat="server" Value='<%# Eval("StudId") %>' />
<asp:TemplateField HeaderText="Meassage">
    <asp:Label ID="lblMessage" runat="server" Text='<%# Eval("Message") %>'></asp:Label>
        <asp:Button ID="btnSendMsg" runat="server" Text="Send"
            onclick="btnSendMsg_Click" />

my button click event


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)
             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
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
2. Use page method for send mail

1 solution

Rate this: bad
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;
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.170713.1 | Last Updated 9 May 2013
Copyright © CodeProject, 1999-2017
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