Sign in to follow this  
thoth

Strange Problem with updatechart and leading zeros in the link...please help

Recommended Posts

I have a strange and annoying problem that I cannot seem to solve on my own. I have a column3d bar chart and each column contains a link. The links are supposed to update a gridview that resides below the chart. The link in each column is essentially supposed to be a 3-digit number that ranges anywhere from 000 to 999. The problem is that any links that start with a leading "0" (numbers such as 010, 048, 061, 070) dont seem to function properly. All the columns/links that start with any digit besides "0" work fine, but when clicking on any columns that start with a "0" returns no-results to the gridview! I am at a loss on what to do!

I can perform manual queries (using leading digit "0" in SQL Server Managment Studio and even hard code them on my page using the same data reader / line of code that the chart and gridview are using and the queries work fine. But when I try to pass the parameter as a link in the chart, any columns starting with "0" don't work.

The links in the columns pass the 3 digit number as a parameter using  the following code:

//Iterate through database

while (oRs.ReadData.Read())

{

// create link to javascript function for ajax post back call

string link = "javascript:updateChart(" + oRs.ReadData["STRAIGHT"].ToString() + ")";

//Create set element

strXML.AppendFormat("<set label='{0}' value='{1}' toolText=' {0} hit {1} times. ' link='{2}' />", oRs.ReadData["STRAIGHT"].ToString(), oRs.ReadData["LIFETIME"].ToString(), link);

}

The event handler that catches the parameter on postback is.....

protected void Page_Load(object sender, EventArgs e)

{

//This will execute first time the page loads and not on ajax post back calls

if (!IsPostBack)

{

ChangeChart();

GameCount();

GridViewDefaults();

}

else

{

// Handle Ajax PostBack Call

// store Asp.Net Ajax special HTTP request

// __EVENTARGUMENT holds value passed by JS function -__doPostBack

//The value can be like "drillDown$1"

//We take $ as delimiter so we get drillDown as the function to call

//and 0 as the factory id. It can vary depending on the pie slice clicked.

String sEventArguments = Request["__EVENTARGUMENT"];

if (sEventArguments != null)

{

//extract arguments passed to the HTTP Request

Int32 iDelimiter = sEventArguments.IndexOf('$');

String sArgument = sEventArguments.Substring(iDelimiter + 1);

// extract the name of the post back function

if (sEventArguments.StartsWith("LifetimeGrid"))

{

// call the post back function passing the argument(s)

LifetimeGrid(sArgument);

}

}

}

}

The code all resides in the code-behind. In the main .aspx page I have the following relevent code for the chart...

<td class="ChartArea" colspan="2">

<script language="javascript" type="text/javascript">

function updateChart(STRAIGHT)

{

__doPostBack(

"<%=Panel3.UniqueID%>","LifetimeGrid$" + STRAIGHT);

}

</script>

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">

<ContentTemplate>.....

I should probably mention that the relevent database columns are all set as varchar(3) in all the tables that are used in the queries.

You can view the page and chart here:

http://stats.active-lotto.com/Ohio/Straights/LifetimeFrequency.aspx

To see the problem select "Top 20", then choose "Midday" from the dropdown list and click "Go". Notice that when you click any columns that represent numbers starting with "0", you get no results in the gridview below, yet all other columns work fine.

Ill be pullin my hair out on this one. I'm not sure what the cause of this problem is or how to correct it. Any help would greatly be appreciated.

Edited by Guest

Share this post


Link to post
Share on other sites

Well I seemed to have found a solution in a different post.

I changed the link to:

// create link to javascript function for ajax post back call

string link = "javascript:updateChart(%26apos;" + oRs.ReadData["STRAIGHT"].ToString() + "%26apos;)";

this works fine now.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this