Click here to Skip to main content
15,922,584 members

Comments by Dmytro Bogachev (Top 7 by date)

Dmytro Bogachev 29-Nov-13 8:26am View    
You don't have to make any returns; changes in your function GetExcelData:
1. Inside of function, remove all declarations of datasets;
2. Remove return (you have void return type, check in my answer);
Since your parameters are ds1, ds2, ds3, this is new code of your data filling:
command1.Fill(ds1);
command2.Fill(ds2);
command3.Fill(ds3);
3. And since you declared datasets before passing them to this function, they will be filled with data. You don't have to return them. They are reference types, so when calling function, they are passed by reference. Here is link about passing parameters in C#, and you can find there info about passing by value and passing by reference:
http://msdn.microsoft.com/en-us/library/vstudio/0f66670z.aspx
Dmytro Bogachev 29-Nov-13 7:05am View    
There is something we're missing about your question. Control should be initialized already on Page_Load. Maybe you're using Custom Controls and your link button is in custom control, maybe there is some issue about cache, if you use it, but anyways it is not about code you posted here. I suggest you open new question with brief description of your current page structure, which will ask, why lnkUrl is null during Page_Load event.
Dmytro Bogachev 29-Nov-13 6:04am View    
One of possible reasons - this control is not yet initialized. What is the event (Page event), in which you're having code, that throws exception?
Dmytro Bogachev 29-Nov-13 6:00am View    
So your problem is not in above code, it is correct. Show please code, where you're getting lnkUrl. Basically it's about this control.
Dmytro Bogachev 29-Nov-13 5:53am View    
Did you try Debug? What is exact line of your exception? There are 2 possible points of failure in above code, Session["ddlCountry"].ToString() - if ToString() for some reason returns null (and I don't see reason for this behavior) and if lnkUrl.Text is null - this is also weird.