Click here to Skip to main content
16,020,345 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hii,

i want to store string into my sql table name:Sentence and my code is:

C#
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e, GridViewRowEventArgs e1)
        {
            if (e.CommandName == "click")
            {
                int _myColumnIndex1 = 0;

                string text = e1.Row.Cells[_myColumnIndex1].Text;

                String[] sentences = Regex.Split(text, @"(?<=[.!?])\s+(?=\p{Lt})");


            }
        }
Posted
Comments
Maciej Los 26-Feb-15 1:43am    
And the issue is...
vatsaldesai 26-Feb-15 1:46am    
its gridview doesent parse two grideviewEvents its shows me error
See my answer.

1 solution

Refer - GridView.RowCommand Event[^].

You should pass only two Event Arguments not three. Store the RowIndex in CommandArgument, so that you can get the Current Row. Explained below.
C#
void GridView1_RowCommand(Object sender, GridViewCommandEventArgs e)
{
    // Your logic
    // To get the Row, do the following
    if(e.CommandName == "click")
    {
        // Convert the row index stored in the CommandArgument
        // property to an Integer.
        int index = Convert.ToInt32(e.CommandArgument);

        // Retrieve the row that contains the button clicked 
        // by the user from the Rows collection.      
        GridViewRow row = GridView1.Rows[index];
     
        // Now get any column value from the "row" and do what u want to do.
    }
}
 
Share this answer
 
v2
Comments
vatsaldesai 26-Feb-15 4:19am    
sir its works but its shows me command argument is not in correct formate so whats problem & should i write this:
<asp:Button ID="btn1" Text="Split into Sentences" runat="server" CommandName="click" CommandArgument=""/>
As I said, you should store the RowIndex in CommandArgument like...

<asp:Button ID="btn1" Text="Split into Sentences" runat="server" CommandName="click" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" />
vatsaldesai 26-Feb-15 4:48am    
Thank You very Much sir....
Please accept the answer and up-vote.

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