16 Answers, 1 is accepted
0
Casey
Top achievements
Rank 1
answered on 05 Sep 2012, 06:07 PM
Hi James,
Do you want the value in the first column, of the first row, or of every row, or from a selected row?
Casey
Do you want the value in the first column, of the first row, or of every row, or from a selected row?
Casey
0
James
Top achievements
Rank 1
answered on 06 Sep 2012, 07:51 AM
Hi there, I need all the values in first column from every row
0
James
Top achievements
Rank 1
answered on 07 Sep 2012, 08:09 AM
Problem resolved
0
Ravi
Top achievements
Rank 1
answered on 14 Feb 2014, 04:39 PM
hey james please support me .
i have a radgrid and a text box . i want to store selected row datakey in text box on with selected a row ?
please give me complite code i'm a new in this field .....
i have a radgrid and a text box . i want to store selected row datakey in text box on with selected a row ?
please give me complite code i'm a new in this field .....
0
Shinu
Top achievements
Rank 2
answered on 15 Feb 2014, 03:54 AM
Hi Ravi Sharma,
I guess you want to display the selected row DataKeyValue in the TextBox. You can access the selected row in the OnSelectedIndexChanged event of the RadGrid, set EnablePostBackOnRowClick=true for the RadGrid for this event to fire.
ASPX:
C#:
Thanks,
Shinu
I guess you want to display the selected row DataKeyValue in the TextBox. You can access the selected row in the OnSelectedIndexChanged event of the RadGrid, set EnablePostBackOnRowClick=true for the RadGrid for this event to fire.
ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" OnSelectedIndexChanged="RadGrid1_SelectedIndexChanged"> <MasterTableView DataKeyNames="ID"> </MasterTableView> <ClientSettings Selecting-AllowRowSelect="true" EnablePostBackOnRowClick="true"> </ClientSettings></telerik:RadGrid><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>C#:
protected void RadGrid1_SelectedIndexChanged(object sender, EventArgs e){ foreach (GridDataItem item in RadGrid1.SelectedItems) { TextBox1.Text= item.GetDataKeyValue("ID").ToString(); //Get the selected row DataKeyValue }}Thanks,
Shinu
0
Ravi
Top achievements
Rank 1
answered on 15 Feb 2014, 04:29 AM
hey shinu thanks for it .
i'm using vb langues please give me code in vb
i'm using vb langues please give me code in vb
0
Shinu
Top achievements
Rank 2
answered on 15 Feb 2014, 04:35 AM
Hi Ravi Sharma,
Here is the VB code:
VB:
Thanks,
Shinu
Here is the VB code:
VB:
Protected Sub RadGrid1_SelectedIndexChanged(sender As Object, e As EventArgs) For Each item As GridDataItem In RadGrid1.SelectedItems 'Get the selected row DataKeyValue TextBox1.Text = item.GetDataKeyValue("ID").ToString() NextEnd SubThanks,
Shinu
0
Ravi
Top achievements
Rank 1
answered on 15 Feb 2014, 04:54 AM
thanks so much shinu this is working better...........
0
Ravi
Top achievements
Rank 1
answered on 15 Feb 2014, 05:31 AM
hi shinu,
i have radgrid and i want to update a table in vb as step given bellow:-
1 select multiple row in grid view
2 updte "yes" value in a table colum where id = selected row id .
my old code is as given bellow as i use in asp grid view as given bellow:-
Private Sub ToggleCheckState(ByVal checkState As Boolean)
For Each row As GridViewRow In GridView1.Rows
Dim cb As CheckBox = row.FindControl("CheckBox1")
If cb IsNot Nothing Then
cb.Checked = checkState
End If
Next
End Sub
____________________________________________________________________________________
Protected Sub COMPLITESELECTION_Click(ByVal sender As Object, ByVal e As EventArgs) Handles COMPLITESELECTION.Click
Dim atLeastOneRowDeleted As Boolean = False
For Each row As GridViewRow In GridView1.Rows
Dim cb As CheckBox = row.FindControl("CheckBox1")
If cb IsNot Nothing AndAlso cb.Checked Then
atLeastOneRowDeleted = True
Dim ID As Integer = Convert.ToInt32(GridView1.DataKeys(row.RowIndex).Value)
'Label1.Text &= String.Format("This would have deleted ProductID {0}<br />", ID)
updateData(ID)
End If
Next
End Sub
pleaste tell me that how i use this code in radgrid........
i have radgrid and i want to update a table in vb as step given bellow:-
1 select multiple row in grid view
2 updte "yes" value in a table colum where id = selected row id .
my old code is as given bellow as i use in asp grid view as given bellow:-
Private Sub ToggleCheckState(ByVal checkState As Boolean)
For Each row As GridViewRow In GridView1.Rows
Dim cb As CheckBox = row.FindControl("CheckBox1")
If cb IsNot Nothing Then
cb.Checked = checkState
End If
Next
End Sub
____________________________________________________________________________________
Protected Sub COMPLITESELECTION_Click(ByVal sender As Object, ByVal e As EventArgs) Handles COMPLITESELECTION.Click
Dim atLeastOneRowDeleted As Boolean = False
For Each row As GridViewRow In GridView1.Rows
Dim cb As CheckBox = row.FindControl("CheckBox1")
If cb IsNot Nothing AndAlso cb.Checked Then
atLeastOneRowDeleted = True
Dim ID As Integer = Convert.ToInt32(GridView1.DataKeys(row.RowIndex).Value)
'Label1.Text &= String.Format("This would have deleted ProductID {0}<br />", ID)
updateData(ID)
End If
Next
End Sub
pleaste tell me that how i use this code in radgrid........
0
Ravi
Top achievements
Rank 1
answered on 15 Feb 2014, 01:19 PM
hi shinu , i'm doing work in vb.
i have a radgrid with multiselection style and a save button as out side of grid.
i want to do that, when i click save button then update my selected row with a value "selected" .
note that i have a special colum in my table and update only those colum
i have a radgrid with multiselection style and a save button as out side of grid.
i want to do that, when i click save button then update my selected row with a value "selected" .
note that i have a special colum in my table and update only those colum
0
Shinu
Top achievements
Rank 2
answered on 17 Feb 2014, 03:24 AM
Hi Ravi Sharma,
Please check the below sample code snippet. I have used a GridClientSelectColumn to select the rows and in the Code-behind on button click i access the selected rows.
ASPX:
VB:
Thanks,
Shinu
Please check the below sample code snippet. I have used a GridClientSelectColumn to select the rows and in the Code-behind on button click i access the selected rows.
ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" DataSourceID="SqlDataSource1" AllowMultiRowSelection="true"> <MasterTableView DataKeyNames="OrderID"> <Columns> <telerik:GridClientSelectColumn UniqueName="CheckBox"> </telerik:GridClientSelectColumn> <telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID" HeaderText="OrderID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" UniqueName="ShipCity"/> </Columns> </MasterTableView> <ClientSettings Selecting-AllowRowSelect="true"> </ClientSettings></telerik:RadGrid><asp:Button ID="Button1" runat="server" Text="Save" OnClick="Button1_Click" />VB:
Protected Sub Button1_Click(sender As Object, e As EventArgs) Dim atLeastOneRowDeleted As Boolean = False For Each items As GridDataItem In RadGrid1.MasterTableView.Items Dim cb As CheckBox = DirectCast(items("CheckBox").Controls(0), CheckBox) If cb IsNot Nothing AndAlso cb.Checked Then atLeastOneRowDeleted = True ' Access DataKeyValue Dim ID As Integer = Convert.ToInt32(items.GetDataKeyValue("OrderID")) 'Access any BoundColumn Dim city As String = items("Shipcity").Text 'Your code End If NextEnd SubThanks,
Shinu
0
Ravi
Top achievements
Rank 1
answered on 17 Feb 2014, 11:03 AM
Thanks alot shinu this is doing best............
0
Ravi
Top achievements
Rank 1
answered on 19 Feb 2014, 06:21 PM
Hey shinu i have a code as given bellow in vb
Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
If (TypeOf e.Item Is GridDataItem) Then
Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)
If (dataItem("name").Text = "pending") Then
dataItem.ForeColor = Drawing.Color.Red
End If
End If
End Sub
this code is change only a column's font color i want to change complite row's color as wherer column value is "pending"
have you any solution
Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
If (TypeOf e.Item Is GridDataItem) Then
Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)
If (dataItem("name").Text = "pending") Then
dataItem.ForeColor = Drawing.Color.Red
End If
End If
End Sub
this code is change only a column's font color i want to change complite row's color as wherer column value is "pending"
have you any solution
0
Shinu
Top achievements
Rank 2
answered on 20 Feb 2014, 04:07 AM
Hi Ravi Sharma,
Your code is correct and working fine at my end. I have attached a screenshot also of what I have obtained.
VB:
Thanks,
Shinu
Your code is correct and working fine at my end. I have attached a screenshot also of what I have obtained.
VB:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) If (TypeOf e.Item Is GridDataItem) Then Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem) If (dataItem("ShipCity").Text = "New York") Then dataItem.ForeColor = System.Drawing.Color.Red End If End IfEnd SubThanks,
Shinu
0
Ravi
Top achievements
Rank 1
answered on 20 Feb 2014, 08:48 AM
hey shinu i saw your attach screen shot and all is better there .
but i don't know that what is mistake in my code so i'm sending my complite code please check that am i missing setting ?
my code is attached
but i don't know that what is mistake in my code so i'm sending my complite code please check that am i missing setting ?
my code is attached
0
Shinu
Top achievements
Rank 2
answered on 21 Feb 2014, 04:35 AM
Hi Ravi Sharma,
Your code looks fine. I was not able to replicate the issue. Please try the sample code snippet given below.
ASPX:
VB:
Thanks,
Shinu
Your code looks fine. I was not able to replicate the issue. Please try the sample code snippet given below.
ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" AllowPaging="true" AllowFilteringByColumn="true" AllowSorting="true" OnNeedDataSource="RadGrid1_NeedDataSource" OnItemDataBound="RadGrid1_ItemDataBound"> <MasterTableView> <Columns> <telerik:GridBoundColumn DataField="ID" HeaderText="ID" UniqueName="ID" /> <telerik:GridBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name" /> <telerik:GridBoundColumn DataField="Number" HeaderText="Number" UniqueName="Number" /> </Columns> </MasterTableView> <ClientSettings Selecting-AllowRowSelect="true"> </ClientSettings></telerik:RadGrid>VB:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) If (TypeOf e.Item Is GridDataItem) Then Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem) If (dataItem("Number").Text = "567") Then dataItem.ForeColor = System.Drawing.Color.Red End If End IfEnd SubThanks,
Shinu