Retrive data from select row in grid and use it to send mail when update in this row

6 posts, 1 answers
  1. Mohamed El-Sayed
    Mohamed El-Sayed avatar
    33 posts
    Member since:
    Apr 2009

    Posted 28 Feb 2013 Link to this post

    Hello , My Name Is Mohamed , and i need assistant in getting data from selected row  :
    when i update in this cell i want to use the name to retrieve the mail address from DB and send mail with C# that the cell is updated with the new value :

    when i choose from the drop down list " manger confirmation " i want to check the name in databse and retrieve the user mail and send mail for him with this update



    ASP:
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticUpdates="True"
            AutoGenerateEditColumn="True" CellSpacing="0" DataSourceID="SqlDataSource1"
            GridLines="None" AllowSorting="True" AllowPaging="True">
            <ClientSettings Selecting-AllowRowSelect="true" EnablePostBackOnRowClick="True">
              
            </ClientSettings>
            <MasterTableView autogeneratecolumns="False" datakeynames="V_ID"
                datasourceid="SqlDataSource1" EditMode="PopUp" >
                <CommandItemSettings ExportToPdfText="Export to PDF" >
                </CommandItemSettings>
                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                </RowIndicatorColumn>
                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"
                    ButtonType="PushButton" HeaderButtonType="PushButton">
                </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridBoundColumn DataField="V_ID" DataType="System.Int32"
                        FilterControlAltText="Filter V_ID column" HeaderText="No#"
                        SortExpression="V_ID" UniqueName="V_ID" ReadOnly="True">
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn DataField="U_Name"
                        FilterControlAltText="Filter U_Name column" HeaderText="Employee Name"
                        Reorderable="False" SortExpression="U_Name" UniqueName="U_Name">
                        <EditItemTemplate>
                            <asp:TextBox ID="U_NameTextBox" runat="server" Text='<%# Bind("U_Name") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="U_NameLabel" runat="server" Text='<%# Eval("U_Name") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn DataField="V_Issue_Date" DataType="System.DateTime"
                        FilterControlAltText="Filter V_Issue_Date column" HeaderText="Issue Date"
                        Reorderable="False" SortExpression="V_Issue_Date" UniqueName="V_Issue_Date">
                        <EditItemTemplate>
                            <asp:TextBox ID="V_Issue_DateTextBox" runat="server"
                                Text='<%# Bind("V_Issue_Date") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="V_Issue_DateLabel" runat="server"
                                Text='<%# Eval("V_Issue_Date", "{0:dd/MM/yyyy}") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn DataField="V_Type"
                        FilterControlAltText="Filter V_Type column" HeaderText="Vacation Type"
                        Reorderable="False" SortExpression="V_Type" UniqueName="V_Type">
                        <EditItemTemplate>
                            <asp:TextBox ID="V_TypeTextBox" runat="server" Text='<%# Bind("V_Type") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="V_TypeLabel" runat="server" Text='<%# Eval("V_Type") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn DataField="V_Start_Date" DataType="System.DateTime"
                        FilterControlAltText="Filter V_Start_Date column" HeaderText="Start Date"
                        Reorderable="False" SortExpression="V_Start_Date" UniqueName="V_Start_Date">
                        <EditItemTemplate>
                            <asp:TextBox ID="V_Start_DateTextBox" runat="server"
                                Text='<%# Bind("V_Start_Date") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="V_Start_DateLabel" runat="server"
                                Text='<%# Eval("V_Start_Date", "{0:dd/MM/yyyy}") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn DataField="V_End_Date" DataType="System.DateTime"
                        FilterControlAltText="Filter V_End_Date column" HeaderText="End Date"
                        Reorderable="False" SortExpression="V_End_Date" UniqueName="V_End_Date">
                        <EditItemTemplate>
                            <asp:TextBox ID="V_End_DateTextBox" runat="server"
                                Text='<%# Bind("V_End_Date") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="V_End_DateLabel" runat="server" Text='<%# Eval("V_End_Date", "{0:dd/MM/yyyy}") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn DataField="Total_Days" DataType="System.Int32"
                        FilterControlAltText="Filter Total_Days column" HeaderText="Total Days"
                        Reorderable="False" SortExpression="Total_Days" UniqueName="Total_Days">
                        <EditItemTemplate>
                            <asp:TextBox ID="Total_DaysTextBox" runat="server"
                                Text='<%# Bind("Total_Days") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Total_DaysLabel" runat="server" Text='<%# Eval("Total_Days") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn DataField="V_Start_Time" DataType="System.TimeSpan"
                        FilterControlAltText="Filter V_Start_Time column" HeaderText="Start Time"
                        Reorderable="False" SortExpression="V_Start_Time" UniqueName="V_Start_Time">
                        <EditItemTemplate>
                            <asp:TextBox ID="V_Start_TimeTextBox" runat="server"
                                Text='<%# Bind("V_Start_Time") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="V_Start_TimeLabel" runat="server"
                                Text='<%# Eval("V_Start_Time") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn DataField="V_End_Time" DataType="System.TimeSpan"
                        FilterControlAltText="Filter V_End_Time column" HeaderText="End Time"
                        Reorderable="False" SortExpression="V_End_Time" UniqueName="V_End_Time">
                        <EditItemTemplate>
                            <asp:TextBox ID="V_End_TimeTextBox" runat="server"
                                Text='<%# Bind("V_End_Time") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="V_End_TimeLabel" runat="server" Text='<%# Eval("V_End_Time") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn DataField="V_Reason"
                        FilterControlAltText="Filter V_Reason column" HeaderText="Reason"
                        Reorderable="False" SortExpression="V_Reason" UniqueName="V_Reason">
                        <EditItemTemplate>
                            <asp:TextBox ID="V_ReasonTextBox" runat="server" Text='<%# Bind("V_Reason") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="V_ReasonLabel" runat="server" Text='<%# Eval("V_Reason") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn DataField="V_Dep_Mgr_Confirmation"
                        FilterControlAltText="Filter V_Dep_Mgr_Confirmation column"
                        HeaderText="Manger Confirmation" SortExpression="V_Dep_Mgr_Confirmation"
                        UniqueName="V_Dep_Mgr_Confirmation">
                        <EditItemTemplate>
                            
     
          <asp:DropDownList ID="DropDownList4" runat="server" BackColor="#ffff99" Text='<%# Bind("V_Dep_Mgr_Confirmation") %>' >
                  <asp:ListItem></asp:ListItem>
                  <asp:ListItem>Confirmed</asp:ListItem>
                  <asp:ListItem>N't Confirmed</asp:ListItem>
        </asp:DropDownList>
     
     
     
     
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="V_Dep_Mgr_ConfirmationLabel" runat="server"
                                Text='<%# Eval("V_Dep_Mgr_Confirmation") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn DataField="V_Dep_Mgr_Comment"
                        FilterControlAltText="Filter V_Dep_Mgr_Comment column"
                        HeaderText="Manger Comment" SortExpression="V_Dep_Mgr_Comment"
                        UniqueName="V_Dep_Mgr_Comment">
                        <EditItemTemplate>
                            <asp:TextBox ID="V_Dep_Mgr_CommentTextBox" BackColor="#ffff99"  runat="server"
                                Text='<%# Bind("V_Dep_Mgr_Comment") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="V_Dep_Mgr_CommentLabel" runat="server"
                                Text='<%# Eval("V_Dep_Mgr_Comment") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn DataField="U_Serial_Number" DataType="System.Int32"
                        FilterControlAltText="Filter U_Serial_Number column"
                        HeaderText="Employee Serial Number" Reorderable="False"
                        SortExpression="U_Serial_Number" UniqueName="U_Serial_Number"
                        Visible="False">
                        <EditItemTemplate>
                            <asp:TextBox ID="U_Serial_NumberTextBox" runat="server"
                                Text='<%# Bind("U_Serial_Number") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="U_Serial_NumberLabel" runat="server"
                                Text='<%# Eval("U_Serial_Number") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
                <EditFormSettings>
                    <EditColumn  FilterControlAltText="Filter EditCommandColumn column"
                        ButtonType="PushButton"   UpdateText="Are You Sure"  EditText="Edit" HeaderButtonType="PushButton">
                    </EditColumn>
                </EditFormSettings>
                <EditItemStyle ForeColor="Red" />
            </MasterTableView>
            <FilterMenu EnableImageSprites="False">
            </FilterMenu>
            <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
            </HeaderContextMenu>
        </telerik:RadGrid>
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 01 Mar 2013 Link to this post

    Hi,

    I guess you want to retrieve selected value from DropDownList in UpdateCommand. Here is the sample code.
    C#:
    protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
    {     
            GridEditableItem EditItem = (GridEditableItem)e.Item;
            DropDownList DDl = (DropDownList)EditItem.FindControl("DropDownList4");
            string DDLSelectedString = DDl.SelectedItem.ToString();
            if (DDLSelectedString == "Confirmed")
            {
                //Query to Check the Name in Database
            }   
    }

    Thanks,
    Shinu

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mohamed El-Sayed
    Mohamed El-Sayed avatar
    33 posts
    Member since:
    Apr 2009

    Posted 01 Mar 2013 Link to this post

    Thx Shinu For This Part !, also I need To Retrive From The User Name In Update , And use It In Sql querry To Retrive His Mail and send It with The Confirmation To Him 
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 01 Mar 2013 Link to this post

    Hi,

    I guess you want to get the TextBox value during Update command. Please check the following code snippet.

    C#:
    protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
    {     
            GridEditableItem EditItem = (GridEditableItem)e.Item;
            DropDownList DDl = (DropDownList)EditItem.FindControl("DropDownList4");
            string DDLSelectedString = DDl.SelectedItem.ToString();
            if (DDLSelectedString == "Confirmed")
            {
                TextBox txtUserName = (TextBox)EditItem.FindControl("U_NameTextBox");
                string UserName = txtUserName.Text;
                //your code
            }   
    }

    Thanks,
    Shinu.
  6. Mohamed El-Sayed
    Mohamed El-Sayed avatar
    33 posts
    Member since:
    Apr 2009

    Posted 02 Mar 2013 Link to this post

    Thx Shinu again :D , Gr8 Supporting , i've one issue else :) , why the values is n't appearing in the text box except after i make render to the page even with update panel also i've to make a render to show the data which retrived from the dropdown list or the textbox 
  7. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 05 Mar 2013 Link to this post

    Hi Mohamed,

    I am afraid it is difficult to figure out your exact requirement. Please check out the following topic for updating the grid records manually:
    http://www.telerik.com/help/aspnet-ajax/grid-insert-update-delete-at-database-level.html

    Hope this helps.

    Greetings,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017