How to Get only Particular value from a grid panel on selected Row

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    How to Get only Particular value from a grid panel on selected Row

    I have my grid panel as follows

    <ext:GridPanel ID="GridPanel1" runat="server" Height="300" Title="Title">
        <ColumnModel runat="server">
            <Columns>
            </Columns>
        </ColumnModel>
        <Store>
            <ext:Store ID="Store1" runat="server" EnableViewState="true">
            </ext:Store>
        </Store>
        <SelectionModel>
            <ext:RowSelectionModel ID="RowSelectionModel1" SingleSelect="true" runat="server">
            </ext:RowSelectionModel>
        </SelectionModel>
        <Buttons>
            <ext:Button ID="btnDelete" runat="server" Text="Delete">
                <DirectEvents>
                    <Click OnEvent="Delete">
                        <ExtraParams>
                            <ext:Parameter Name="Values" Value="Ext.encode(#{GridPanel1}.getRowsValues({selectedOnly:true}))"
                                Mode="Raw" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
        </Buttons>
    </ext:GridPanel>
    This is my grid from my database

    Click image for larger version. 

Name:	Grid.png 
Views:	98 
Size:	3.3 KB 
ID:	3928

    This is my code to delete the selected row but this is looping for row value as i used dictionary

    protected void Delete(object sender, DirectEventArgs e)
       {
           string json = e.ExtraParams["Values"];
           string value = string.Empty;
           Dictionary<string, string>[] companies = JSON.Deserialize<Dictionary<string, string>[]>(json);
           bool addHeader = true;
     
           foreach (Dictionary<string, string> row in companies)
           {
               if (addHeader)
               {
                   //sb.Append("<tr>");
                   foreach (KeyValuePair<string, string> keyValuePair in row)
                   {
                       value = keyValuePair.Value.ToString();
                       SqlConnection con = new SqlConnection(connection);
                       con.Open();
                       SqlCommand cmd = new SqlCommand("Delete from Users where Name='" + value + "'", con);
                       cmd.ExecuteNonQuery();
                       BindData();
                   }
                   addHeader = false;
               }
           }
       }
    If I select first row and click on delete I would like to delete that row and Bind grid again. Can any one tell how to do this. Also I would like to alert a message box if the user didn't select any row using Java script
    Last edited by Dorababu; Mar 10, 2012 at 5:12 AM.

Similar Threads

  1. How to get values from grid panel selected row
    By mehmood in forum 1.x Help
    Replies: 9
    Last Post: Apr 11, 2012, 12:09 PM
  2. pass parameter by selected row in grid panel
    By vahid.ch in forum 1.x Help
    Replies: 0
    Last Post: Dec 19, 2011, 11:05 AM
  3. Filter Grid Panel by Selected Rows
    By JIGSAW in forum 1.x Help
    Replies: 2
    Last Post: Feb 25, 2011, 12:46 PM
  4. Replies: 0
    Last Post: Jan 28, 2010, 2:47 AM
  5. How to clear selected row in grid panel.
    By Satyanarayana murthy in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 25, 2009, 8:22 AM

Posting Permissions