Mohamed El-Sayed
Top achievements
Rank 1
Mohamed El-Sayed
asked on 08 May 2014, 06:30 PM
Dears ,
I have a rad grid contain data and instead use edit to but value in one cell for every row , I want to create a two buttons in every row to put this value
Ex:
the cell in database name " mgm_con" I want when I press in the button to put in this cell " confirmed " or the second button " n't confirmed "
I have a rad grid contain data and instead use edit to but value in one cell for every row , I want to create a two buttons in every row to put this value
Ex:
the cell in database name " mgm_con" I want when I press in the button to put in this cell " confirmed " or the second button " n't confirmed "
7 Answers, 1 is accepted
0
Mohamed El-Sayed
Top achievements
Rank 1
answered on 08 May 2014, 06:33 PM
and if there is availability to put also a text box name in Db " Reason" to add text in it and after press in any of the two button make this row disappeared and n't to show in the grid
0
Shinu
Top achievements
Rank 2
answered on 09 May 2014, 08:22 AM
Hi Beka,
I am not sure about the requirements. Following my assumptions about the requirement. Please have a look on the following steps.
1. Update the Database value 'mgm_con' onClick of the RadButton and also reflect the updation in RadGrid.
2. Hide a particular row by checking the value in the TextBox being added into another column.
ASPX:
C#:
Let me know if you have any concern.
Thanks,
Shinu.
I am not sure about the requirements. Following my assumptions about the requirement. Please have a look on the following steps.
1. Update the Database value 'mgm_con' onClick of the RadButton and also reflect the updation in RadGrid.
2. Hide a particular row by checking the value in the TextBox being added into another column.
ASPX:
<telerik:RadGrid ID="radgrdOrders" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" CellSpacing="-1" GridLines="Both"> <MasterTableView DataKeyNames="CountryId"> <Columns> <telerik:GridBoundColumn DataField="CountryName" UniqueName="CountryName"> <ColumnValidationSettings> <ModelErrorMessage Text=""></ModelErrorMessage> </ColumnValidationSettings> </telerik:GridBoundColumn> <telerik:GridTemplateColumn> <ItemTemplate> <telerik:RadButton ID="radbtnConfirm" runat="server" Text="ConfirmButton" OnClick="radbtnConfirm_Click"> </telerik:RadButton> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn> <ItemTemplate> <telerik:RadButton ID="radbtnNotConfirm" runat="server" Text="NotConfirmButton" OnClick="radbtnNotConfirm_Click"> </telerik:RadButton> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn> <ItemTemplate> <telerik:RadTextBox ID="radTxtReason" runat="server"> </telerik:RadTextBox> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </MasterTableView></telerik:RadGrid>C#:
protected void UpdateGrid(GridDataItem item, string datakey, string updateText){ string connectionstring = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; SqlConnection sqlconn = new SqlConnection(connectionstring); RadTextBox textBox = (RadTextBox)item.FindControl("radTxtReason"); if (textBox.Text != string.Empty) { item.Visible = false; } else { sqlconn.Open(); SqlCommand updateCommand = new SqlCommand("UPDATE Country SET CountryName=@CountryName WHERE CountryId=@UpdateValue", sqlconn); updateCommand.Parameters.AddWithValue("@UpdateValue", datakey); updateCommand.Parameters.AddWithValue("@CountryName", updateText); updateCommand.ExecuteScalar(); sqlconn.Close(); radgrdOrders.Rebind(); }}protected void radbtnConfirm_Click(object sender, EventArgs e){ RadButton Button = (RadButton)sender; GridDataItem item = (GridDataItem)Button.NamingContainer; string datakey = item.GetDataKeyValue("CountryId").ToString(); string updateText = "Confimed"; UpdateGrid(item,datakey,updateText);}protected void radbtnNotConfirm_Click(object sender, EventArgs e){ RadButton Button = (RadButton)sender; GridDataItem item = (GridDataItem)Button.NamingContainer; string datakey = item.GetDataKeyValue("CountryId").ToString(); string updateText = "NotConfimed"; UpdateGrid(item, datakey, updateText);}Let me know if you have any concern.
Thanks,
Shinu.
0
Mohamed El-Sayed
Top achievements
Rank 1
answered on 09 May 2014, 03:57 PM
Sorry Shinu I tried but it didn't work a lot of errors
look may this info help :
Ex :
DB :
one table " Home "
H_ID
H_Adress
H_status
I want to use the grid to get those data and I want to use the buttons in the H_status , confirm or n't confirm
could you try to check by this way
look may this info help :
Ex :
DB :
one table " Home "
H_ID
H_Adress
H_status
I want to use the grid to get those data and I want to use the buttons in the H_status , confirm or n't confirm
could you try to check by this way
0
Shinu
Top achievements
Rank 2
answered on 12 May 2014, 03:27 AM
Hi Beka,
Please have a look into0 the sample code snippet which works fine at my end.
ASPX:
C#:
Please provide your full code if it doesn't help.
Thanks,
Shinu.
Please have a look into0 the sample code snippet which works fine at my end.
ASPX:
<telerik:RadGrid ID="radgrdOrders" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" CellSpacing="-1" GridLines="Both"> <MasterTableView DataKeyNames="H_ID"> <Columns> <telerik:GridBoundColumn DataField="H_status" UniqueName="H_status"> </telerik:GridBoundColumn> <telerik:GridTemplateColumn> <ItemTemplate> <telerik:RadButton ID="radbtnConfirm" runat="server" Text="ConfirmButton" OnClick="radbtnConfirm_Click"> </telerik:RadButton> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn> <ItemTemplate> <telerik:RadButton ID="radbtnNotConfirm" runat="server" Text="NotConfirmButton" OnClick="radbtnNotConfirm_Click"> </telerik:RadButton> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </MasterTableView></telerik:RadGrid>C#:
protected void radbtnConfirm_Click(object sender, EventArgs e){ RadButton Button = (RadButton)sender; GridDataItem item = (GridDataItem)Button.NamingContainer; string datakey = item.GetDataKeyValue("H_ID").ToString(); string updateText = "Confimed"; UpdateGrid(item,datakey,updateText);}protected void radbtnNotConfirm_Click(object sender, EventArgs e){ RadButton Button = (RadButton)sender; GridDataItem item = (GridDataItem)Button.NamingContainer; string datakey = item.GetDataKeyValue("H_ID").ToString(); string updateText = "NotConfimed"; UpdateGrid(item, datakey, updateText);}protected void UpdateGrid(GridDataItem item, string datakey, string updateText){ string connectionstring = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; SqlConnection sqlconn = new SqlConnection(connectionstring); sqlconn.Open(); SqlCommand updateCommand = new SqlCommand("UPDATE Home SET H_status=@H_status WHERE H_ID=@UpdateValue", sqlconn); updateCommand.Parameters.AddWithValue("@UpdateValue", datakey); updateCommand.Parameters.AddWithValue("@H_status", updateText); updateCommand.ExecuteScalar(); sqlconn.Close(); radgrdOrders.Rebind();}Please provide your full code if it doesn't help.
Thanks,
Shinu.
0
Mohamed El-Sayed
Top achievements
Rank 1
answered on 14 May 2014, 11:39 AM
Thanks SHINU it worked
0
Mohamed El-Sayed
Top achievements
Rank 1
answered on 14 May 2014, 05:31 PM
thanks SHINU it worked very well , I just also need to retrieve the data when I press for ex: when I press on confirm I want to get the data of this row
H_ID
H_Adress
H_status
using this code to send it in mail and add the details in the body of the mail
H_ID
H_Adress
H_status
using this code to send it in mail and add the details in the body of the mail
SmtpClient client = new SmtpClient(); client.DeliveryMethod = SmtpDeliveryMethod.Network; client.EnableSsl = true; client.Host = "smtp.gmail.com"; client.Port = 587; // setup Smtp authentication System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("xxxx@yyy", "xxxx"); client.UseDefaultCredentials = false; client.Credentials = credentials; MailMessage msg = new MailMessage(); msg.From = new MailAddress("xxxx@yyy"); msg.To.Add("mm@zzz"); msg.Subject = (" new "); msg.IsBodyHtml = true; msg.Body = (""); try { client.Send(msg); } catch (Exception ex) { }0
Shinu
Top achievements
Rank 2
answered on 15 May 2014, 04:43 AM
Hi Beka,
You can try the following code snippet in the confirm button click to access the row values.
C#:
Thanks,
Shinu
You can try the following code snippet in the confirm button click to access the row values.
C#:
protected void radbtnConfirm_Click(object sender, EventArgs e){ RadButton rbtnConfirm= (RadButton)sender; GridDataItem dataItem = (GridDataItem)rbtnConfirm.NamingContainer; string H_ID= dataItem .GetDataKeyValue("H_ID").ToString(); //Access dataKey value string H_Adress = dataItem["H_Adress "].Text;// Access a BoundColumn value // Your code }Thanks,
Shinu