Showing posts with label datagrid. Show all posts
Showing posts with label datagrid. Show all posts

Wednesday, March 28, 2012

Accessing SelectedIndex of Datagrid inside a bound Accordion Control

I have a bound Accordion Control with its Content Template containing a gridview. Each Gridview is populated on the Accordion ItemDataBound.

The Gridview containes a set of bound checkboxes with autopostback set to true.

When a checkbox is clicked i need to find the selectedindex of the row in the gridview in question. I'm trying to retreive the selected index from within the form load event.

Any ideas?

Just to let you know, if you have your checkbox inside the GridView, you have to find the control within the GridView first and then see what is the selected value or index.

CheckBox myCheckBox = (CheckBox) GridView1.FindControl("myCheckBox1");

int i = myCheckBox.SelectedIndex;

Just one more thing, Enable Tracing for your page Trace="true" in the <%@.Page Language=... so you can see what is the name for your control. Because if you are using master page the names would be auto generated with a prefix.

Hope this would be any help to you.

Regards,
Mehdi


Just to let you know, if you have your checkbox inside the GridView, you have to find the control within the GridView first and then see what is the selected value or index.

CheckBox myCheckBox = (CheckBox) GridView1.FindControl("myCheckBox1");

int i = myCheckBox.SelectedIndex;

Just one more thing, Enable Tracing for your page Trace="true" in the <%@.Page Language=... so you can see what is the name for your control. Because if you are using master page the names would be auto generated with a prefix.

Hope this would be any help to you.

Regards,
Mehdi


Thanks for the reply.

It doesn't realy help as firstly I need to find the gridview within the accordion control, then find the datakey of the row (checkbox) that's been clicked on.

I'm not sure how to index the accordion control as it's bound and doesn't use the panes collection?

Wednesday, March 21, 2012

A circular reference was detected while serializing an object of type "System.goblaization

Hi all,

I am trying to call a webservice through javascript to return a dataset to bind it to a datagrid on the client side.

I am using a scriptmanager and registered the service by setting the service path.

I am calling a method on a Textbox onKeydown event to call the webservice method. The web service is returning the a data set. But the problem is am geting an exception stating the following

The server method 'GetDataSet' failed with the following error: System.InvalidOperationException-- A Circular reference was detected while serializing an object of type "System.Globalization.CultureInfo"

Please help me out.

See the following code to get an idea about the problem i have

<WebMethod(EnableSession:=True)> _

PublicFunction GetDataSet(ByVal prefixTextAsString)As DataSet

Dim dtAs DataTable

dt =New DataTable

Dim drAs DataRow

dt =Me.GetSelectedTestSchema()

dr =Me.PopulateSelectedTestsRow("1020","dafda", dt)

Try

dt.Rows.Add(dr)

Catch exAs Exception

EndTry

Dim dsAs DataSet =New DataSet()

ds.Tables.Add(dt)

Return ds

EndFunction

Javascript code

function GenerateGrid()

{

var myGrid = igtbl_getGridById("grdSelectedTests");

TestListService.GetDataSet("x",OnWebRequestComplete);

// myGrid.Control.Set_DataDataSource(TestListService.GetDataSet("x").Table[0]);

//

}

function OnWebRequestComplete(results)

{

'I am using the Infragistics ultraWebgrid

var grdControl = igtbl_getGridById("grdSelectedTests");

grdControl.control.set_data(results);

}

Scriptmanager code

<asp:ScriptManagerID="ScriptManager1"runat="server">

<Services>

<asp:ServiceReferencePath="../AutoCompleteServices/TestListService.asmx"/>

</Services>

</asp:ScriptManager>

Hi,

According to my understanding to your problem, I don't think it's a AJAX specific issue. The exception is related to your server side code.

Can you debug your server side code to try to solve it?

Or you may post the code for methods:GetSelectedTestSchema() andPopulateSelectedTestsRow here.


We are marking this issue as "Answered". If you have any new findings or concerns, please feel free to unmark the issue.


I too am having the same problems.

I'm using C# to write my webservice, I have almost an identical setup for the client-side scripts.


I get this error even when returning an empty DataSet.


 [WebMethod]public DataSet GetData() {return new DataSet(); }

Does anyone know what this error message is telling me? I tried debugging it, and no exception is thrown from the webservice and it works fine when I send a soap request to it.

Thanks,

Lee


You may try to overcome it by setting response format to XML. For instance:

[System.Web.Script.Services.ScriptMethod(ResponseFormat=System.Web.Script.Services.ResponseFormat.Xml)]
public DataSet GetData()
{