Telerik Forums
UI for ASP.NET AJAX Forum
6 answers
226 views

Problem description:

The sample project contains a RadGrid (2 columns, 4 rows) that switches the  second column in the second and fourth rows in edit mode. The problem is that the first column does not display its value anymore (the value is "lost") while the second column is in edit mode. When I try to iterate through all the rows in Save_Command handler, I cannot get the value from these columns either.


Default.aspx

<%

@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%

@ Register TagPrefix="tlk" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

<%

@ Register TagPrefix="ajax" Namespace="System.Web.UI" Assembly="System.Web.Extensions" %>

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

html xmlns="http://www.w3.org/1999/xhtml">

<

head runat="server">

<title>Untitled Page</title>

</

head>

<

body>

<form id="form1" runat="server">

<ajax:ScriptManager ID="ScriptManager" runat="server">

</ajax:ScriptManager>

<tlk:RadGrid ID="RadGrid1" Width="100%" AllowMultiRowEdit="true"

OnNeedDataSource="RadGrid_NeedDataSource" runat="server"

OnItemCreated="RadGrid1_ItemCreated" >

<MasterTableView ShowHeadersWhenNoRecords="true" Width="100%" AutoGenerateColumns="false" EditMode="InPlace" >

<Columns>

<tlk:GridBoundColumn UniqueName="Name" HeaderText="Name" DataField="Name" />

<tlk:GridBoundColumn UniqueName="Amount" HeaderText="Amount" DataField="Amount" />

</Columns>

<EditItemStyle BackColor="transparent" />

</MasterTableView>

<ClientSettings>

<Resizing AllowColumnResize="true" AllowRowResize="true" />

<Scrolling AllowScroll="true" UseStaticHeaders="true" />

</ClientSettings>

<HeaderStyle Width="150px" />

</tlk:RadGrid>

<div style="text-align:right; margin-top:5px">

<asp:Button ID="SaveButton" Text="Save" runat="server" OnCommand="Save_Command" />

</div>

</form>

</

body>

</

html>

Default.aspx.cs

using

System;

using

System.Data;

using

System.Configuration;

using

System.Collections;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Web.UI.HtmlControls;

using

Telerik.Web.UI;

public

partial class _Default : System.Web.UI.Page

{

protected void RadGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)

{

DataTable table = new DataTable();

table.Columns.Add(

new DataColumn("Name"));

table.Columns.Add(

new DataColumn("Amount"));

table.Rows.Add(

new object[] { "John", "11" });

table.Rows.Add(

new object[] { "David", "22" });

table.Rows.Add(

new object[] { "Elvis", "33" });

table.Rows.Add(

new object[] { "Oliver", "44" });

((

RadGrid)source).DataSource = table;

}

protected void Page_PreRender(object sender, EventArgs e)

{

RadGrid1.Items[1].Edit =

true;

RadGrid1.Items[3].Edit =

true;

RadGrid1.Rebind();

}

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)

{

if (e.Item is GridDataItem && e.Item.IsInEditMode)

{

foreach (GridColumn column in e.Item.OwnerTableView.RenderColumns)

{

if (column is GridBoundColumn)

{

if (string.Compare(column.UniqueName, "Amount", StringComparison.InvariantCultureIgnoreCase) == 0)

{

((

GridBoundColumn)column).ReadOnly = false;

TextBox textBox = null;

if (e.Item is GridDataItem)

{

textBox = ((

TextBox)((GridDataItem)e.Item)[column.UniqueName].Controls[0]);

textBox.Style[

"width"] = "100%";

textBox.Style[

"height"] = "100%";

textBox.Style[

"border"] = "1px";

textBox.Style[

"text-align"] = "right";

}

}

else

{

((

GridBoundColumn)column).ReadOnly = true;

}

}

}

}

}

protected void Save_Command(object source, EventArgs e)

{

string name = "";

foreach (GridDataItem item in RadGrid1.Items)

{

name = item[

"Name"].Text;

}

}

}


I also have a second question: I would like to have an extra row to show the rollup on the editable column. Is it possible to have this total being updated as the user modifies the editable fields ?

Acadia
Top achievements
Rank 1
Iron
 answered on 22 Aug 2008
1 answer
180 views

Hi,
I am trying to retrieve data from a Rad Grid and inserting it into a dataset.
I am using the following code, but somehow it's not working.  I would appreciate it if you could tell me how I should get it to work.


Imports System.Data.SqlClient
Imports System.Data
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
    Dim dt As DataTable = New System.Data.DataTable("Parameters")
    Dim ds As New DataSet
    Dim column As DataColumn
    Dim row As DataRow

    column = New DataColumn
    column.DataType = System.Type.GetType("System.String")
    column.ColumnName = "ParameterID"
    column.Unique = True
    dt.Columns.Add(column)

    column = New DataColumn
    column.DataType = System.Type.GetType("System.String")
    column.ColumnName = "ParameterDesc"
    column.Unique = True
    dt.Columns.Add(column)

    Dim PrimaryKeyColumns(0) As DataColumn
    PrimaryKeyColumns(0) = dt.Columns("ParameterID")
    dt.PrimaryKey = PrimaryKeyColumns

    ds.Tables.Add(dt)

    For Each Item In RadGrid1.MasterTableView.Items
        row = dt.NewRow
        row("ParameterID") = Item.Cells(0).Text
        row("ParameterDesc") = Item.Cells(1).Text
        dt.Rows.Add(row)
    Next
End Sub


Thank you,
Al
Kiara
Top achievements
Rank 1
 answered on 22 Aug 2008
5 answers
138 views

Hello,
         I am using radgrid. Inside my grid, I have GridEditCommandColumn.
While clicking on the update button there, I am handling "Radgrid1_UpdateCommand". But inside "Radgrid1_UpdateCommand", I am not able to run
"Response.Write("<script language='javascript'>alert('My Message.')</script>");"

So may I know the reason along with solution?
Thanks in advance.
Daniel
Telerik team
 answered on 22 Aug 2008
3 answers
174 views
Hello,

I want to change the FooterStyle.BackColor on DetailTableDataBind, after i check the sum of a column. Unfortunetly, this does not happen wright away, but after annother DetailTableDataBind is fired. Do I have to do a Rebind() for this to work?

Thanks
Kiara
Top achievements
Rank 1
 answered on 22 Aug 2008
3 answers
113 views
Hi

I have a grid control .it creates the grid is in this pattern
Question1:
        Answer1.(Text Area ID="txtAnswer")
        Anwer2.(Text Area  ID="txtAnswer")
 Question 2:
            Answer 1:(Text area ID="txtAnswer")
    Question 3:
        No answer:

It creates dynamically .
How I can attach the the spell control for all the Answers ?

Thanks,
AR
Rumen
Telerik team
 answered on 22 Aug 2008
3 answers
159 views

Hi
I'm trying to add text description and linkbuttons to the groupdheaderitem of a grid.  I've added the controls in both ItemDataBound and ItemCreated grid events.   As per the samples I'm using 

DataRowView groupDataRow = e.Item.DataItem as DataRowView;

to access the data for the row, but this is not available on postback and I can't find another way to get the data for the row. 
I can't access the DatakeyValues in ItemCommand events as the itemindex isn't set on the group header.
Is there another way to customize the contents of the group header to include buttons that will postback correctly and allow me to identify the data row for the event?

I'm using the latest version of the grid. 

Thanks

Kiara
Top achievements
Rank 1
 answered on 22 Aug 2008
2 answers
284 views
Hi,

i have a RadGrid on my ASPX Page. When i use the build in control to change the page size a System.StackOverflowException is thrown in the PageSizeChanged Event during assign the new page size (grid.PageSize = e.NewPageSize. In debugging the the event is never left.

Can someone help me?


Christian
Christian
Top achievements
Rank 1
 answered on 22 Aug 2008
4 answers
416 views
I've tried to figure this out but this one piece is stumping me.  I'm sure it's easy for one of the more experienced rad users or Telerk, but I'm not seeing it.

I have a Rad Grid for Ajax with a textbox column that when in edit mode is a Rad Combobox.  When I switch to edit mode I want the combobox to be set to the value of the textbox.  The combobox is populated on demand in edit mode, which might be the problem, but I don't know how else to populate the combobox when I enter edit mode.

Is there a way to retrieve the original value of the textbox in the following method and set the combo to that after I populate the combo?

Public

Sub rcLt_ItemsRequested(ByVal sender As Object, ByVal e As RadComboBoxItemsRequestedEventArgs)

Dim itemsList As String() = {"J", "G"}

Dim comboBox As RadComboBox = DirectCast(sender, RadComboBox)

comboBox.Items.Clear()

comboBox.DataSource = itemsList

comboBox.DataBind()

'How do I retrieve the value of the textbox from before I entered edit mode?

End Sub

If somebody could give me some guidanc on this that would be great!

Thanks

Acadia
Top achievements
Rank 1
Iron
 answered on 22 Aug 2008
3 answers
242 views
Hi,

The "SavedOldValues"  returns empty hashtable.
Please help.  

Private Sub GridViewControl_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles GridViewControl.ItemCommand

If (e.CommandName = RadGrid.UpdateCommandName) Then

If (e.Item.GetType.ToString = "Telerik.Web.UI.GridEditFormItem") Then

Dim editedItem As GridEditFormItem = CType(e.Item, GridEditFormItem)

_Session(

"RadGrid.SavedOldValues") = editedItem.SavedOldValues

End If

End If

End Sub

Wilson

Kiara
Top achievements
Rank 1
 answered on 22 Aug 2008
8 answers
437 views
Hi,

I want to add 2 bottons in group header in order to export data to excel/word?
Can you help me?  Thx.
Twalker
Top achievements
Rank 1
 answered on 22 Aug 2008
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?