Click here to Skip to main content
15,918,742 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionHow to fire the DropDownList.SelectedIndexChanged event Pin
MacIntyre19-Nov-09 7:09
MacIntyre19-Nov-09 7:09 
AnswerRe: How to fire the DropDownList.SelectedIndexChanged event Pin
Abhishek Sur19-Nov-09 8:19
professionalAbhishek Sur19-Nov-09 8:19 
GeneralRe: How to fire the DropDownList.SelectedIndexChanged event Pin
MacIntyre19-Nov-09 10:12
MacIntyre19-Nov-09 10:12 
GeneralRe: How to fire the DropDownList.SelectedIndexChanged event Pin
MacIntyre19-Nov-09 11:49
MacIntyre19-Nov-09 11:49 
GeneralRe: How to fire the DropDownList.SelectedIndexChanged event Pin
Abhishek Sur19-Nov-09 21:10
professionalAbhishek Sur19-Nov-09 21:10 
Questionobject data source Pin
Tauseef A19-Nov-09 7:03
Tauseef A19-Nov-09 7:03 
QuestionCould somebosy help me this rendercontrol issue Pin
Ersan Ercek19-Nov-09 6:40
Ersan Ercek19-Nov-09 6:40 
AnswerRe: Could somebosy help me this rendercontrol issue Pin
Abhishek Sur19-Nov-09 7:56
professionalAbhishek Sur19-Nov-09 7:56 
Hey....

I am very sorry, I didnt saw your last replies. First of all, it seems that your GridView is inside an updatepanel. If this is the case it cant be rendered. It will throw an error like Control 'Grid' of type 'GridView'must be placed inside a form tag with runat=server.


Actually RenderControl looks for Form Element when it Renders. So if you place it as a ContentItem of UpdatePanel, it will not take it as a direct element of HtmlForm. Hence it cant execute RenderControl of the control. So, here is the solution :

//Place this in your code behind to remove the controls. This might be a general function which can be used for any types.
private void ClearElements(Control ctrl)
{
    for (int i = ctrl.Controls.Count - 1; i >= 0; i--)
    {
        ClearElements(ctrl.Controls[i]);
    }

    if (!(ctrl is TableCell)) //Check for TableCell and replace with Literal
    {
        if (ctrl.GetType().GetProperty("SelectedItem") != null)
        {
            LiteralControl literal = new LiteralControl();
            ctrl.Parent.Controls.Add(literal);
            try
            {
                literal.Text =ctrl.GetType().GetProperty("SelectedItem").GetValue(ctrl, null) as string;
            }
            catch
            {}
            ctrl.Parent.Controls.Remove(ctrl);
        }
        else if (ctrl.GetType().GetProperty("Text") != null)//Get parent control and remove it
        {
            LiteralControl literal = new LiteralControl();
            ctrl.Parent.Controls.Add(literal);
            literal.Text = ctrl.GetType().GetProperty("Text").GetValue(ctrl, null) as string;
            ctrl.Parent.Controls.Remove(ctrl);
        }
    }
    return;
}


//Replace the code snippet in your code just where you wrote :
StringBuilder sb = new StringBuilder();
StringWriter strw = new StringWriter(sb);
HtmlTextWriter htmlw = new HtmlTextWriter(strw);
ClearElements(dgSiparisler);
HtmlForm form = new HtmlForm();
Controls.Add(form);
form.Controls.Add(dgSiparisler);
form.RenderControl(htmlw);

snd.sendconMail("cinersan@hotmail.com", sb.ToString(), "Üyelik Bilgileri");


I think this will solve your issue.
Thumbs Up | :thumbsup:

Abhishek Sur
Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->

Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript

GeneralRe: Could somebosy help me this rendercontrol issue Pin
Ersan Ercek19-Nov-09 9:07
Ersan Ercek19-Nov-09 9:07 
GeneralRe: Could somebosy help me this rendercontrol issue Pin
Abhishek Sur19-Nov-09 20:40
professionalAbhishek Sur19-Nov-09 20:40 
GeneralRe: Could somebosy help me this rendercontrol issue Pin
Ersan Ercek19-Nov-09 20:55
Ersan Ercek19-Nov-09 20:55 
GeneralRe: Could somebosy help me this rendercontrol issue Pin
Abhishek Sur19-Nov-09 21:08
professionalAbhishek Sur19-Nov-09 21:08 
GeneralRe: Could somebosy help me this rendercontrol issue Pin
Ersan Ercek20-Nov-09 0:59
Ersan Ercek20-Nov-09 0:59 
GeneralRe: Could somebosy help me this rendercontrol issue Pin
Abhishek Sur21-Nov-09 9:25
professionalAbhishek Sur21-Nov-09 9:25 
GeneralRe: Could somebosy help me this rendercontrol issue Pin
Ersan Ercek23-Nov-09 0:28
Ersan Ercek23-Nov-09 0:28 
GeneralRe: Could somebosy help me this rendercontrol issue Pin
Abhishek Sur24-Nov-09 21:42
professionalAbhishek Sur24-Nov-09 21:42 
AnswerRe: Could somebosy help me this rendercontrol issue Pin
The Man from U.N.C.L.E.19-Nov-09 7:59
The Man from U.N.C.L.E.19-Nov-09 7:59 
GeneralRe: Could somebosy help me this rendercontrol issue Pin
The Man from U.N.C.L.E.19-Nov-09 8:01
The Man from U.N.C.L.E.19-Nov-09 8:01 
GeneralRe: Could somebosy help me this rendercontrol issue Pin
Abhishek Sur19-Nov-09 8:10
professionalAbhishek Sur19-Nov-09 8:10 
GeneralRe: Could somebosy help me this rendercontrol issue Pin
Ersan Ercek19-Nov-09 8:20
Ersan Ercek19-Nov-09 8:20 
QuestionOpen Documents from List Box Pin
Paul Unsworth19-Nov-09 4:47
Paul Unsworth19-Nov-09 4:47 
AnswerRe: Open Documents from List Box Pin
Abhijit Jana19-Nov-09 5:04
professionalAbhijit Jana19-Nov-09 5:04 
GeneralRe: Open Documents from List Box Pin
Paul Unsworth19-Nov-09 5:33
Paul Unsworth19-Nov-09 5:33 
GeneralRe: Open Documents from List Box Pin
Christian Graus19-Nov-09 6:21
protectorChristian Graus19-Nov-09 6:21 
GeneralRe: Open Documents from List Box Pin
Paul Unsworth19-Nov-09 21:24
Paul Unsworth19-Nov-09 21:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.