顯示具有 Menu 標籤的文章。 顯示所有文章
顯示具有 Menu 標籤的文章。 顯示所有文章

2014年7月13日 星期日

[RESOLVED] How to retrieve Image from database and pass through query string


My question i have a image in database, i want to retrieve and show in my home page , when i change menu , the image will be move through querystriing on the next menu. and i use the asp imagecontrol to hold the image in the master pasge


Can You show me step by step process  from image retrieval from database to image show on pages..


can i make u understand?


Good Explaination will be highly appreciable





ramanujbasu



Can You show me step by step process  from image retrieval from database to image show on pages..





check this


http://aspsnippets.com/Articles/Display-Images-from-SQL-Server-Database-using-ASP.Net.aspx


hope this helps...



Hi,


About Inserting And Reading Image To/From Database in ASP.NET (Web Application) in Image Control:


http://www.c-sharpcorner.com/uploadfile/17e8f6/inserting-and-reading-image-tofrom-database-in-Asp-Net-web-application-in-image-control/


Hope it can help you


[RESOLVED] Line up drop down menu items?


Hi,


Using the code below I am populating a drop down menu but the text does not line up. Is there a way so that when the drop down loads that the City part is all in line? Currently the city part can be more to left or more to the right depending on the length
of the column before it? Thanks!


While reader.Read
customers.Add(reader("Provider Last Name (Legal Name)").ToString + ", " + reader("Provider First Name").ToString + " " + reader("Provider Business Mailing Address City Name").ToString + ", " + reader("Provider Business Mailing Address State Name").ToString + " " + reader("Provider Business Mailing Address Postal Code").ToString)

End While



I've created some similar functionality in the past for aligning items within Dropdowns that leverages the empty character (ALT+255) to create spaces within drop-downs that are recognized within


It uses some of the available padding within the String formatting function to allocate exactly how many characters you want to use for a specific field and then has an additional function to replace those spaces with the "invisible character" : 


string FormatForDropDown(string s, int length)
{
//Builds a string
StringBuilder sb = new StringBuilder();
//Iterates through and replaces the empty values with the empty character (not a space)
for (int i = 0; i < length; i++)
{
sb.Append((i < s.Length) ? s[i].ToString() : " ");
}
//Outputs the string
return sb.ToString();
}

and as far as actually adding the actual entry, it should be used as such : 


//Example of the item you would add to your Drop-down list
String.Format("{0,24} | {1,12} | {2,24}", FormatForDropDown(valueA, 24), FormatForDropDown(valueB, 12), FormatForDropDown(valueC, 24));

(Warning : This is old code)







Since you are using Visual Basic, it may look something like this : 


Public Function FormatForDropDown(ByVal s As String, ByVal length As Integer) As String
Dim sb = New StringBuilder()
For i As Integer = 0 To length
sb.Append(If(i < s.Length, s(i).ToString(), " "))
Next
Return sb.ToString()
End Function

and


'String to Add'
Dim entry = String.Format("{0,24} | {1,24} | {2,24} | {3,24} | {4, 24}",reader("Provider Last Name (Legal Name)").ToString(),reader("Provider Business Mailing Address City Name").ToString(), reader("Provider First Name").ToString(),reader("Provider Business Mailing Address State Name").ToString(), reader("Provider Business Mailing Address Postal Code").ToString()
'Add the entry'
customers.Add(entry)

Alternatively, you could simply replace the strings of spaces that you are using with the invisible character " " as mentioned : 


While reader.Read
customers.Add(reader("Provider Last Name (Legal Name)").ToString() + ", " + reader("Provider First Name").ToString + "          " + reader("Provider Business Mailing Address City Name").ToString() + ", " + reader("Provider Business Mailing Address State Name").ToString() + "  " + reader("Provider Business Mailing Address Postal Code").ToString())
End While

I attempted to replace them in the code above however it may not have worked properly. It's just important to note that all of the spaces that you see above within your strings are not actual spaces but the invisible character (ALT+255).







Thanks, this seems to be close to what i need, proglem is some of the last names have a "-" so it throws off the alignment. Thanks for your help with this. Maybe can it be a set width so its like an excel sheet where its just like a straight line between
with a set length?


               JOHNSON |                    AJITA |                     BEAR |                       DE |                197013036


               JOHNSON-Smith |                    AJITA |                     BEAR |                       DE |                197013036


 


[RESOLVED] calling Checkbox checked Event


I've a repeater and in repeater i've check box list..wheck is generated dynamically.


How i can call check box checked Even


here is code








<%#GetGroupName(Eval("MENU_MODIFIER_GROUP_NAME_TRANSLATION_ID").ToString().Trim())%>
[Free :
<%#GetFreeQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
]   [max:

<%#GetMaxQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
]






<%-- --%>
runat="server">









Set cbl Autopostback="true"


CheckedChanged event is for CheckBox instead CheckBoxList


CheckBoxList is using SelectedIndexChanged


This sample for CheckBox


    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
CheckBox cb = (CheckBox)sender;
RepeaterItem ri = (RepeaterItem)cb.NamingContainer;
HiddenField hdngrpOpid = (HiddenField)ri.FindControl("hdngrpOpid");
int idx = ri.ItemIndex;




}












<%#GetGroupName(Eval("MENU_MODIFIER_GROUP_NAME_TRANSLATION_ID").ToString().Trim())%>
[Free :
<%#GetFreeQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
]   [max:

<%#GetMaxQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
]






<%-- --%>
runat="server" AutoPostBack="true" onselectedindexchanged="cbxControl_SelectedIndexChanged" >





On Code Behind
protected void cbxControl__SelectedIndexChanged(object sender, EventArgs e)
{

}


[RESOLVED] From Visual Studio in “design view”, is possible to have the correspondig lines of code highlighted in “source view”?


I use VS2010 with GridView, FormView ecc...


I frequently switch from Design View (in which for example I am visually editing something inside a FormView EditItemTemplate), to Source View.


Note that this happen when I am editing something inside a EditItemTemplate


So, for example if in Design View I have a TextBox selected, when I switch to Source View I'd like to have ONLY the corresponding lines selected, instead VS2010 highligh ALL the FormView EditItemtemplate code, from start to finish (which can be 1000 lines
long!).


Is possible or not to instruct VS to select only the relevant lines?




No it is not posible.



Because gridview is one control and you are placing another controls inside it. So it is consider as part fo grid view so it will select whole grid view. And also you can not directly access that control in code behind just because of same reason.




Wait!


Now it is functioning correctly!


From Design view:



  1. I select an TextBox --> ... is selected in source view
  2. I click in a cell -->
  3. I highligh a full table row in design --> the code inside ... is selected in source, wonderful!


From source view:



  1. I click wherever in a line inside the whole table is highlighted in design view
  2. I click inside a the control is highlighted in design view

  3. WONDERFUL!!! Surprised


    So, what the hell has got messed before, and what I have done in the meantime that reset things?


    (In the meantime I have close and reopend VS (not working), rebuild solution, refactored code, reformatted code, changed formatting tag options, ecc...)



    Arrghhh!!!


    I edited the code from the Source view, removing a

    line, the VS asked me to refresh the view, claiming that Design view is out of sync with Source view.


    I clicked to synchronize view, and now it's not functioning anymore!!! Yell


    I thought it could be because some background VS task didn't have yet enough time to complete, so I waited ... but after something like 10 minutes of wait it's not working yet....


    So, I clicked undo to insert the

    lines back... and (not so surprisingly) the highlight works again!!!


    What is happening???



    PS: Important info. If instead I remove the

    line from the Design view, via mouse dx popup menu-->Delete rows-->Delete row the Source/Design remains in synch and the highlight functionality continue working Undecided



    Up to now I have found this workaround... that seems to be working :-)


    You have manually edited the source code, so messing up the synchronize with design view...!



    1. Select a control in Design view
    2. Change something in the Properties window, (for example set width=100px, or toggle the Enabled property)
    3. WAIT.... (your change forces VS to update the source code!)
    4. After some time (something like 5-10 seconds for my slow machine ;-)), VS updates the code, adding/changing the relevant code 
    5. And now the bidirectional highlight functionality works again!
    6. Remember to Change back/Toggle the modified property Tongue Out 

    [RESOLVED] How to retrieve Image from database and pass through query string


    My question i have a image in database, i want to retrieve and show in my home page , when i change menu , the image will be move through querystriing on the next menu. and i use the asp imagecontrol to hold the image in the master pasge


    Can You show me step by step process  from image retrieval from database to image show on pages..


    can i make u understand?


    Good Explaination will be highly appreciable





    ramanujbasu



    Can You show me step by step process  from image retrieval from database to image show on pages..





    check this


    http://aspsnippets.com/Articles/Display-Images-from-SQL-Server-Database-using-ASP.Net.aspx


    hope this helps...



    Hi,


    About Inserting And Reading Image To/From Database in ASP.NET (Web Application) in Image Control:


    http://www.c-sharpcorner.com/uploadfile/17e8f6/inserting-and-reading-image-tofrom-database-in-Asp-Net-web-application-in-image-control/


    Hope it can help you


    [RESOLVED] Line up drop down menu items?


    Hi,


    Using the code below I am populating a drop down menu but the text does not line up. Is there a way so that when the drop down loads that the City part is all in line? Currently the city part can be more to left or more to the right depending on the length
    of the column before it? Thanks!


    While reader.Read
    customers.Add(reader("Provider Last Name (Legal Name)").ToString + ", " + reader("Provider First Name").ToString + " " + reader("Provider Business Mailing Address City Name").ToString + ", " + reader("Provider Business Mailing Address State Name").ToString + " " + reader("Provider Business Mailing Address Postal Code").ToString)

    End While



    I've created some similar functionality in the past for aligning items within Dropdowns that leverages the empty character (ALT+255) to create spaces within drop-downs that are recognized within


    It uses some of the available padding within the String formatting function to allocate exactly how many characters you want to use for a specific field and then has an additional function to replace those spaces with the "invisible character" : 


    string FormatForDropDown(string s, int length)
    {
    //Builds a string
    StringBuilder sb = new StringBuilder();
    //Iterates through and replaces the empty values with the empty character (not a space)
    for (int i = 0; i < length; i++)
    {
    sb.Append((i < s.Length) ? s[i].ToString() : " ");
    }
    //Outputs the string
    return sb.ToString();
    }

    and as far as actually adding the actual entry, it should be used as such : 


    //Example of the item you would add to your Drop-down list
    String.Format("{0,24} | {1,12} | {2,24}", FormatForDropDown(valueA, 24), FormatForDropDown(valueB, 12), FormatForDropDown(valueC, 24));

    (Warning : This is old code)







    Since you are using Visual Basic, it may look something like this : 


    Public Function FormatForDropDown(ByVal s As String, ByVal length As Integer) As String
    Dim sb = New StringBuilder()
    For i As Integer = 0 To length
    sb.Append(If(i < s.Length, s(i).ToString(), " "))
    Next
    Return sb.ToString()
    End Function

    and


    'String to Add'
    Dim entry = String.Format("{0,24} | {1,24} | {2,24} | {3,24} | {4, 24}",reader("Provider Last Name (Legal Name)").ToString(),reader("Provider Business Mailing Address City Name").ToString(), reader("Provider First Name").ToString(),reader("Provider Business Mailing Address State Name").ToString(), reader("Provider Business Mailing Address Postal Code").ToString()
    'Add the entry'
    customers.Add(entry)

    Alternatively, you could simply replace the strings of spaces that you are using with the invisible character " " as mentioned : 


    While reader.Read
    customers.Add(reader("Provider Last Name (Legal Name)").ToString() + ", " + reader("Provider First Name").ToString + "          " + reader("Provider Business Mailing Address City Name").ToString() + ", " + reader("Provider Business Mailing Address State Name").ToString() + "  " + reader("Provider Business Mailing Address Postal Code").ToString())
    End While

    I attempted to replace them in the code above however it may not have worked properly. It's just important to note that all of the spaces that you see above within your strings are not actual spaces but the invisible character (ALT+255).







    Thanks, this seems to be close to what i need, proglem is some of the last names have a "-" so it throws off the alignment. Thanks for your help with this. Maybe can it be a set width so its like an excel sheet where its just like a straight line between
    with a set length?


                   JOHNSON |                    AJITA |                     BEAR |                       DE |                197013036


                   JOHNSON-Smith |                    AJITA |                     BEAR |                       DE |                197013036


     


    [RESOLVED] calling Checkbox checked Event


    I've a repeater and in repeater i've check box list..wheck is generated dynamically.


    How i can call check box checked Even


    here is code








    <%#GetGroupName(Eval("MENU_MODIFIER_GROUP_NAME_TRANSLATION_ID").ToString().Trim())%>
    [Free :
    <%#GetFreeQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
    ]   [max:

    <%#GetMaxQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
    ]






    <%-- --%>
    runat="server">









    Set cbl Autopostback="true"


    CheckedChanged event is for CheckBox instead CheckBoxList


    CheckBoxList is using SelectedIndexChanged


    This sample for CheckBox


        protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
    CheckBox cb = (CheckBox)sender;
    RepeaterItem ri = (RepeaterItem)cb.NamingContainer;
    HiddenField hdngrpOpid = (HiddenField)ri.FindControl("hdngrpOpid");
    int idx = ri.ItemIndex;




    }












    <%#GetGroupName(Eval("MENU_MODIFIER_GROUP_NAME_TRANSLATION_ID").ToString().Trim())%>
    [Free :
    <%#GetFreeQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
    ]   [max:

    <%#GetMaxQuantity(Eval("MENU_MODIFIER_GROUP_ID").ToString().Trim())%>
    ]






    <%-- --%>
    runat="server" AutoPostBack="true" onselectedindexchanged="cbxControl_SelectedIndexChanged" >





    On Code Behind
    protected void cbxControl__SelectedIndexChanged(object sender, EventArgs e)
    {

    }


    [RESOLVED] From Visual Studio in “design view”, is possible to have the correspondig lines of code highlighted in “source view”?


    I use VS2010 with GridView, FormView ecc...


    I frequently switch from Design View (in which for example I am visually editing something inside a FormView EditItemTemplate), to Source View.


    Note that this happen when I am editing something inside a EditItemTemplate


    So, for example if in Design View I have a TextBox selected, when I switch to Source View I'd like to have ONLY the corresponding lines selected, instead VS2010 highligh ALL the FormView EditItemtemplate code, from start to finish (which can be 1000 lines
    long!).


    Is possible or not to instruct VS to select only the relevant lines?




    No it is not posible.



    Because gridview is one control and you are placing another controls inside it. So it is consider as part fo grid view so it will select whole grid view. And also you can not directly access that control in code behind just because of same reason.




    Wait!


    Now it is functioning correctly!


    From Design view:



    1. I select an TextBox --> ... is selected in source view
    2. I click in a cell -->
    3. I highligh a full table row in design --> the code inside
    ... is selected in source, wonderful!


    From source view:



    1. I click wherever in a line inside
    the whole table is highlighted in design view
  4. I click inside a the control is highlighted in design view

  5. WONDERFUL!!! Surprised


    So, what the hell has got messed before, and what I have done in the meantime that reset things?


    (In the meantime I have close and reopend VS (not working), rebuild solution, refactored code, reformatted code, changed formatting tag options, ecc...)



    Arrghhh!!!


    I edited the code from the Source view, removing a

    line, the VS asked me to refresh the view, claiming that Design view is out of sync with Source view.


    I clicked to synchronize view, and now it's not functioning anymore!!! Yell


    I thought it could be because some background VS task didn't have yet enough time to complete, so I waited ... but after something like 10 minutes of wait it's not working yet....


    So, I clicked undo to insert the

    lines back... and (not so surprisingly) the highlight works again!!!


    What is happening???



    PS: Important info. If instead I remove the

    line from the Design view, via mouse dx popup menu-->Delete rows-->Delete row the Source/Design remains in synch and the highlight functionality continue working Undecided



    Up to now I have found this workaround... that seems to be working :-)


    You have manually edited the source code, so messing up the synchronize with design view...!



    1. Select a control in Design view
    2. Change something in the Properties window, (for example set width=100px, or toggle the Enabled property)
    3. WAIT.... (your change forces VS to update the source code!)
    4. After some time (something like 5-10 seconds for my slow machine ;-)), VS updates the code, adding/changing the relevant code 
    5. And now the bidirectional highlight functionality works again!
    6. Remember to Change back/Toggle the modified property Tongue Out 

    [RESOLVED] Not able to Hide/remove a ChildNode from a Repeater bound to SitemapDatasource


    Hi All,


    Please help me to hide/remove a child node. I am able to hide a nodeby setting visible property to false but not able to hide a child node. My code


    .ASPX CODE





  6. <%# Eval("Title") %>






    • <%# Eval("Title") %>










  7. Code Behind Code on Repeater OnItemDataBound="menu_ItemDataBound":


    SqlDataSource SqlDataSource1 = new SqlDataSource();
    SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["IDMServicesDatabaseConnectionString"].ConnectionString;

    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    SiteMapNode thisMapNode = (SiteMapNode)e.Item.DataItem;
    thisMapNode.ReadOnly = false;
    if (thisMapNode.Title == "Admin")
    {
    if (Page.User.IsInRole("enterprisenet.org\\gbs idm Shift leads"))
    {
    e.Item.Visible = true;
    }
    else
    {
    e.Item.Visible = false;
    }
    }
    else
    {
    SiteMapNodeCollection siteMapCollection = thisMapNode.ChildNodes;
    foreach (SiteMapNode node in siteMapCollection)
    {
    string requestType = node.Title;
    SqlDataSource1.SelectCommand = "SELECT [Visible] FROM [IDMServicesList] where [RequestType]='" + requestType + "'";
    //SqlDataSource1.SelectParameters.Add("RequestType", requestType);
    DataView dv = (System.Data.DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
    if (dv.Count > 0)
    {
    DataRowView drv = dv[0];
    string Visible = drv["Visible"].ToString();
    if (Visible == "Hide")
    {
    node.ChildNodes.Remove(node); }
    }
    }

    }


    }

    Not able to either remove or hide(by setting the visible property) the child node. With the above code to remove node.ChildNodes.Remove(node) getting Collection is read only not supported exception.


    Please help



    Any help would be appreciated...



    i think following line is problematic,


    node.ChildNodes.Remove(node);

    you are trying do delete node from node object, self-delete is not possible :)


    instead try this


      node.ChildNodes.RemoveAll();     OR   node.ChildNodes.Clear();    

    Thanks.








    ijaz_asp



    instead try this


     node.ChildNodes.RemoveAll(); OR node.ChildNodes.Clear(); 




    same error "Collection is Read only" for node.ChildNodes.Clear();  Method Removeall(); does not exist at all



    hmm, if this is the case , try to hide the item instead of deleting it. like if the data-bound item does not fullfill your display/visible logic then get it from template object and set its visibility to none or simply set visible=false.


    thanks



    I am able to set the Visible property (e.Item.Visible =
    false;)
    for the Parent node in ItemDataBound(object
    sender,
    RepeaterItemEventArgs e) but not able to hide the
    hyperlink which is dynamically created using repeater control.


    Please help me with an example



    it may be something like this,


    var hyperlink = e.Item.findControl("ID of HyperLink") as HyperLink;

    if(hyperlink !=null)
    {
    hyperlink.visible=false; // if it does not meet your criteria .
    }

    thanks





    These hyperlinks are dynamically generated in a repeater control. Not sure of the ID.



    Hi,


    The id is you set in makeup code



    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    SiteMapNode thisMapNode = (SiteMapNode)e.Item.DataItem;
    thisMapNode.ReadOnly = false;
    if (thisMapNode.Title == "Admin")
    {
    if (Page.User.IsInRole("enterprisenet.org\\gbs idm Shift leads"))
    {
    e.Item.Visible = true;
    }
    else
    {
    e.Item.Visible = false;
    }
    }
    else
    {
    SiteMapNodeCollection siteMapCollection = thisMapNode.ChildNodes;
    foreach (SiteMapNode node in siteMapCollection)
    {
    string requestType = node.Title;
    SqlDataSource1.SelectCommand = "SELECT [Visible] FROM [IDMServicesList] where [RequestType]='" + requestType + "'";
    //SqlDataSource1.SelectParameters.Add("RequestType", requestType);
    DataView dv = (System.Data.DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
    if (dv.Count > 0)
    {
    DataRowView drv = dv[0];
    string Visible = drv["Visible"].ToString();
    if (Visible == "Hide")
    {
    Repeater thisRepeater = (Repeater)e.Item.FindControl("Repeater1"); HyperLink thisLink = (HyperLink)thisRepeater.FindControl("HyperLink2"); thisLink.Visible = false; }
    }
    }
    }
    }

    I have implemented your code but on the runtime thisLink is null. On thisLink.Visisble, I get object reference not set to instance of an object.






  8. <%# Eval("Title") %>






    • <%# Eval("Title") %>









  9. On the Repeater1 (Inside the menu Repeater) databound event, I am able to find the id of Hyperlink


    HyperLink thisLink = (HyperLink)e.Item.FindControl("HyperLink2");
    if (thisLink != null)
    {
    thisLink.Visible = false;
    }

    Not sure y your code did not work



    Hi,


    Try it like this


     NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %>

    And in code behind define the method isVisible()


    public bool isVisible() 
    {
    if (something ...)
    return true;

    else
    return false;
    }

    And refer the thread


    http://stackoverflow.com/questions/10199698/set-visible-of-a-label-from-code-behind


    http://forums.asp.net/t/1409887.aspx/1


    Hope it can help you




    [RESOLVED] Not able to Hide/remove a ChildNode from a Repeater bound to SitemapDatasource


    Hi All,


    Please help me to hide/remove a child node. I am able to hide a nodeby setting visible property to false but not able to hide a child node. My code


    .ASPX CODE





  10. <%# Eval("Title") %>






    • <%# Eval("Title") %>










  11. Code Behind Code on Repeater OnItemDataBound="menu_ItemDataBound":


    SqlDataSource SqlDataSource1 = new SqlDataSource();
    SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["IDMServicesDatabaseConnectionString"].ConnectionString;

    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    SiteMapNode thisMapNode = (SiteMapNode)e.Item.DataItem;
    thisMapNode.ReadOnly = false;
    if (thisMapNode.Title == "Admin")
    {
    if (Page.User.IsInRole("enterprisenet.org\\gbs idm Shift leads"))
    {
    e.Item.Visible = true;
    }
    else
    {
    e.Item.Visible = false;
    }
    }
    else
    {
    SiteMapNodeCollection siteMapCollection = thisMapNode.ChildNodes;
    foreach (SiteMapNode node in siteMapCollection)
    {
    string requestType = node.Title;
    SqlDataSource1.SelectCommand = "SELECT [Visible] FROM [IDMServicesList] where [RequestType]='" + requestType + "'";
    //SqlDataSource1.SelectParameters.Add("RequestType", requestType);
    DataView dv = (System.Data.DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
    if (dv.Count > 0)
    {
    DataRowView drv = dv[0];
    string Visible = drv["Visible"].ToString();
    if (Visible == "Hide")
    {
    node.ChildNodes.Remove(node); }
    }
    }

    }


    }

    Not able to either remove or hide(by setting the visible property) the child node. With the above code to remove node.ChildNodes.Remove(node) getting Collection is read only not supported exception.


    Please help



    Any help would be appreciated...



    i think following line is problematic,


    node.ChildNodes.Remove(node);

    you are trying do delete node from node object, self-delete is not possible :)


    instead try this


      node.ChildNodes.RemoveAll();     OR   node.ChildNodes.Clear();    

    Thanks.








    ijaz_asp



    instead try this


     node.ChildNodes.RemoveAll(); OR node.ChildNodes.Clear(); 




    same error "Collection is Read only" for node.ChildNodes.Clear();  Method Removeall(); does not exist at all



    hmm, if this is the case , try to hide the item instead of deleting it. like if the data-bound item does not fullfill your display/visible logic then get it from template object and set its visibility to none or simply set visible=false.


    thanks



    I am able to set the Visible property (e.Item.Visible =
    false;)
    for the Parent node in ItemDataBound(object
    sender,
    RepeaterItemEventArgs e) but not able to hide the
    hyperlink which is dynamically created using repeater control.


    Please help me with an example



    it may be something like this,


    var hyperlink = e.Item.findControl("ID of HyperLink") as HyperLink;

    if(hyperlink !=null)
    {
    hyperlink.visible=false; // if it does not meet your criteria .
    }

    thanks





    These hyperlinks are dynamically generated in a repeater control. Not sure of the ID.



    Hi,


    The id is you set in makeup code



    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    SiteMapNode thisMapNode = (SiteMapNode)e.Item.DataItem;
    thisMapNode.ReadOnly = false;
    if (thisMapNode.Title == "Admin")
    {
    if (Page.User.IsInRole("enterprisenet.org\\gbs idm Shift leads"))
    {
    e.Item.Visible = true;
    }
    else
    {
    e.Item.Visible = false;
    }
    }
    else
    {
    SiteMapNodeCollection siteMapCollection = thisMapNode.ChildNodes;
    foreach (SiteMapNode node in siteMapCollection)
    {
    string requestType = node.Title;
    SqlDataSource1.SelectCommand = "SELECT [Visible] FROM [IDMServicesList] where [RequestType]='" + requestType + "'";
    //SqlDataSource1.SelectParameters.Add("RequestType", requestType);
    DataView dv = (System.Data.DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
    if (dv.Count > 0)
    {
    DataRowView drv = dv[0];
    string Visible = drv["Visible"].ToString();
    if (Visible == "Hide")
    {
    Repeater thisRepeater = (Repeater)e.Item.FindControl("Repeater1"); HyperLink thisLink = (HyperLink)thisRepeater.FindControl("HyperLink2"); thisLink.Visible = false; }
    }
    }
    }
    }

    I have implemented your code but on the runtime thisLink is null. On thisLink.Visisble, I get object reference not set to instance of an object.






  12. <%# Eval("Title") %>






    • <%# Eval("Title") %>









  13. On the Repeater1 (Inside the menu Repeater) databound event, I am able to find the id of Hyperlink


    HyperLink thisLink = (HyperLink)e.Item.FindControl("HyperLink2");
    if (thisLink != null)
    {
    thisLink.Visible = false;
    }

    Not sure y your code did not work



    Hi,


    Try it like this


     NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %>

    And in code behind define the method isVisible()


    public bool isVisible() 
    {
    if (something ...)
    return true;

    else
    return false;
    }

    And refer the thread


    http://stackoverflow.com/questions/10199698/set-visible-of-a-label-from-code-behind


    http://forums.asp.net/t/1409887.aspx/1


    Hope it can help you




    [RESOLVED] Not able to Hide/remove a ChildNode from a Repeater bound to SitemapDatasource


    Hi All,


    Please help me to hide/remove a child node. I am able to hide a nodeby setting visible property to false but not able to hide a child node. My code


    .ASPX CODE





  14. <%# Eval("Title") %>






    • <%# Eval("Title") %>










  15. Code Behind Code on Repeater OnItemDataBound="menu_ItemDataBound":


    SqlDataSource SqlDataSource1 = new SqlDataSource();
    SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["IDMServicesDatabaseConnectionString"].ConnectionString;

    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    SiteMapNode thisMapNode = (SiteMapNode)e.Item.DataItem;
    thisMapNode.ReadOnly = false;
    if (thisMapNode.Title == "Admin")
    {
    if (Page.User.IsInRole("enterprisenet.org\\gbs idm Shift leads"))
    {
    e.Item.Visible = true;
    }
    else
    {
    e.Item.Visible = false;
    }
    }
    else
    {
    SiteMapNodeCollection siteMapCollection = thisMapNode.ChildNodes;
    foreach (SiteMapNode node in siteMapCollection)
    {
    string requestType = node.Title;
    SqlDataSource1.SelectCommand = "SELECT [Visible] FROM [IDMServicesList] where [RequestType]='" + requestType + "'";
    //SqlDataSource1.SelectParameters.Add("RequestType", requestType);
    DataView dv = (System.Data.DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
    if (dv.Count > 0)
    {
    DataRowView drv = dv[0];
    string Visible = drv["Visible"].ToString();
    if (Visible == "Hide")
    {
    node.ChildNodes.Remove(node); }
    }
    }

    }


    }

    Not able to either remove or hide(by setting the visible property) the child node. With the above code to remove node.ChildNodes.Remove(node) getting Collection is read only not supported exception.


    Please help



    Any help would be appreciated...



    i think following line is problematic,


    node.ChildNodes.Remove(node);

    you are trying do delete node from node object, self-delete is not possible :)


    instead try this


      node.ChildNodes.RemoveAll();     OR   node.ChildNodes.Clear();    

    Thanks.








    ijaz_asp



    instead try this


     node.ChildNodes.RemoveAll(); OR node.ChildNodes.Clear(); 




    same error "Collection is Read only" for node.ChildNodes.Clear();  Method Removeall(); does not exist at all



    hmm, if this is the case , try to hide the item instead of deleting it. like if the data-bound item does not fullfill your display/visible logic then get it from template object and set its visibility to none or simply set visible=false.


    thanks



    I am able to set the Visible property (e.Item.Visible =
    false;)
    for the Parent node in ItemDataBound(object
    sender,
    RepeaterItemEventArgs e) but not able to hide the
    hyperlink which is dynamically created using repeater control.


    Please help me with an example



    it may be something like this,


    var hyperlink = e.Item.findControl("ID of HyperLink") as HyperLink;

    if(hyperlink !=null)
    {
    hyperlink.visible=false; // if it does not meet your criteria .
    }

    thanks





    These hyperlinks are dynamically generated in a repeater control. Not sure of the ID.



    Hi,


    The id is you set in makeup code



    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    SiteMapNode thisMapNode = (SiteMapNode)e.Item.DataItem;
    thisMapNode.ReadOnly = false;
    if (thisMapNode.Title == "Admin")
    {
    if (Page.User.IsInRole("enterprisenet.org\\gbs idm Shift leads"))
    {
    e.Item.Visible = true;
    }
    else
    {
    e.Item.Visible = false;
    }
    }
    else
    {
    SiteMapNodeCollection siteMapCollection = thisMapNode.ChildNodes;
    foreach (SiteMapNode node in siteMapCollection)
    {
    string requestType = node.Title;
    SqlDataSource1.SelectCommand = "SELECT [Visible] FROM [IDMServicesList] where [RequestType]='" + requestType + "'";
    //SqlDataSource1.SelectParameters.Add("RequestType", requestType);
    DataView dv = (System.Data.DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
    if (dv.Count > 0)
    {
    DataRowView drv = dv[0];
    string Visible = drv["Visible"].ToString();
    if (Visible == "Hide")
    {
    Repeater thisRepeater = (Repeater)e.Item.FindControl("Repeater1"); HyperLink thisLink = (HyperLink)thisRepeater.FindControl("HyperLink2"); thisLink.Visible = false; }
    }
    }
    }
    }

    I have implemented your code but on the runtime thisLink is null. On thisLink.Visisble, I get object reference not set to instance of an object.






  16. <%# Eval("Title") %>






    • <%# Eval("Title") %>









  17. On the Repeater1 (Inside the menu Repeater) databound event, I am able to find the id of Hyperlink


    HyperLink thisLink = (HyperLink)e.Item.FindControl("HyperLink2");
    if (thisLink != null)
    {
    thisLink.Visible = false;
    }

    Not sure y your code did not work



    Hi,


    Try it like this


     NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %>

    And in code behind define the method isVisible()


    public bool isVisible() 
    {
    if (something ...)
    return true;

    else
    return false;
    }

    And refer the thread


    http://stackoverflow.com/questions/10199698/set-visible-of-a-label-from-code-behind


    http://forums.asp.net/t/1409887.aspx/1


    Hope it can help you




    [RESOLVED] Not able to Hide/remove a ChildNode from a Repeater bound to SitemapDatasource


    Hi All,


    Please help me to hide/remove a child node. I am able to hide a nodeby setting visible property to false but not able to hide a child node. My code


    .ASPX CODE





  18. <%# Eval("Title") %>






    • <%# Eval("Title") %>










  19. Code Behind Code on Repeater OnItemDataBound="menu_ItemDataBound":


    SqlDataSource SqlDataSource1 = new SqlDataSource();
    SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["IDMServicesDatabaseConnectionString"].ConnectionString;

    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    SiteMapNode thisMapNode = (SiteMapNode)e.Item.DataItem;
    thisMapNode.ReadOnly = false;
    if (thisMapNode.Title == "Admin")
    {
    if (Page.User.IsInRole("enterprisenet.org\\gbs idm Shift leads"))
    {
    e.Item.Visible = true;
    }
    else
    {
    e.Item.Visible = false;
    }
    }
    else
    {
    SiteMapNodeCollection siteMapCollection = thisMapNode.ChildNodes;
    foreach (SiteMapNode node in siteMapCollection)
    {
    string requestType = node.Title;
    SqlDataSource1.SelectCommand = "SELECT [Visible] FROM [IDMServicesList] where [RequestType]='" + requestType + "'";
    //SqlDataSource1.SelectParameters.Add("RequestType", requestType);
    DataView dv = (System.Data.DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
    if (dv.Count > 0)
    {
    DataRowView drv = dv[0];
    string Visible = drv["Visible"].ToString();
    if (Visible == "Hide")
    {
    node.ChildNodes.Remove(node); }
    }
    }

    }


    }

    Not able to either remove or hide(by setting the visible property) the child node. With the above code to remove node.ChildNodes.Remove(node) getting Collection is read only not supported exception.


    Please help



    Any help would be appreciated...



    i think following line is problematic,


    node.ChildNodes.Remove(node);

    you are trying do delete node from node object, self-delete is not possible :)


    instead try this


      node.ChildNodes.RemoveAll();     OR   node.ChildNodes.Clear();    

    Thanks.








    ijaz_asp



    instead try this


     node.ChildNodes.RemoveAll(); OR node.ChildNodes.Clear(); 




    same error "Collection is Read only" for node.ChildNodes.Clear();  Method Removeall(); does not exist at all



    hmm, if this is the case , try to hide the item instead of deleting it. like if the data-bound item does not fullfill your display/visible logic then get it from template object and set its visibility to none or simply set visible=false.


    thanks



    I am able to set the Visible property (e.Item.Visible =
    false;)
    for the Parent node in ItemDataBound(object
    sender,
    RepeaterItemEventArgs e) but not able to hide the
    hyperlink which is dynamically created using repeater control.


    Please help me with an example



    it may be something like this,


    var hyperlink = e.Item.findControl("ID of HyperLink") as HyperLink;

    if(hyperlink !=null)
    {
    hyperlink.visible=false; // if it does not meet your criteria .
    }

    thanks





    These hyperlinks are dynamically generated in a repeater control. Not sure of the ID.



    Hi,


    The id is you set in makeup code



    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    SiteMapNode thisMapNode = (SiteMapNode)e.Item.DataItem;
    thisMapNode.ReadOnly = false;
    if (thisMapNode.Title == "Admin")
    {
    if (Page.User.IsInRole("enterprisenet.org\\gbs idm Shift leads"))
    {
    e.Item.Visible = true;
    }
    else
    {
    e.Item.Visible = false;
    }
    }
    else
    {
    SiteMapNodeCollection siteMapCollection = thisMapNode.ChildNodes;
    foreach (SiteMapNode node in siteMapCollection)
    {
    string requestType = node.Title;
    SqlDataSource1.SelectCommand = "SELECT [Visible] FROM [IDMServicesList] where [RequestType]='" + requestType + "'";
    //SqlDataSource1.SelectParameters.Add("RequestType", requestType);
    DataView dv = (System.Data.DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
    if (dv.Count > 0)
    {
    DataRowView drv = dv[0];
    string Visible = drv["Visible"].ToString();
    if (Visible == "Hide")
    {
    Repeater thisRepeater = (Repeater)e.Item.FindControl("Repeater1"); HyperLink thisLink = (HyperLink)thisRepeater.FindControl("HyperLink2"); thisLink.Visible = false; }
    }
    }
    }
    }

    I have implemented your code but on the runtime thisLink is null. On thisLink.Visisble, I get object reference not set to instance of an object.






  20. <%# Eval("Title") %>






    • <%# Eval("Title") %>









  21. On the Repeater1 (Inside the menu Repeater) databound event, I am able to find the id of Hyperlink


    HyperLink thisLink = (HyperLink)e.Item.FindControl("HyperLink2");
    if (thisLink != null)
    {
    thisLink.Visible = false;
    }

    Not sure y your code did not work



    Hi,


    Try it like this


     NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %>

    And in code behind define the method isVisible()


    public bool isVisible() 
    {
    if (something ...)
    return true;

    else
    return false;
    }

    And refer the thread


    http://stackoverflow.com/questions/10199698/set-visible-of-a-label-from-code-behind


    http://forums.asp.net/t/1409887.aspx/1


    Hope it can help you




    [RESOLVED] Not able to Hide/remove a ChildNode from a Repeater bound to SitemapDatasource


    Hi All,


    Please help me to hide/remove a child node. I am able to hide a nodeby setting visible property to false but not able to hide a child node. My code


    .ASPX CODE





  22. <%# Eval("Title") %>






    • <%# Eval("Title") %>










  23. Code Behind Code on Repeater OnItemDataBound="menu_ItemDataBound":


    SqlDataSource SqlDataSource1 = new SqlDataSource();
    SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["IDMServicesDatabaseConnectionString"].ConnectionString;

    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    SiteMapNode thisMapNode = (SiteMapNode)e.Item.DataItem;
    thisMapNode.ReadOnly = false;
    if (thisMapNode.Title == "Admin")
    {
    if (Page.User.IsInRole("enterprisenet.org\\gbs idm Shift leads"))
    {
    e.Item.Visible = true;
    }
    else
    {
    e.Item.Visible = false;
    }
    }
    else
    {
    SiteMapNodeCollection siteMapCollection = thisMapNode.ChildNodes;
    foreach (SiteMapNode node in siteMapCollection)
    {
    string requestType = node.Title;
    SqlDataSource1.SelectCommand = "SELECT [Visible] FROM [IDMServicesList] where [RequestType]='" + requestType + "'";
    //SqlDataSource1.SelectParameters.Add("RequestType", requestType);
    DataView dv = (System.Data.DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
    if (dv.Count > 0)
    {
    DataRowView drv = dv[0];
    string Visible = drv["Visible"].ToString();
    if (Visible == "Hide")
    {
    node.ChildNodes.Remove(node); }
    }
    }

    }


    }

    Not able to either remove or hide(by setting the visible property) the child node. With the above code to remove node.ChildNodes.Remove(node) getting Collection is read only not supported exception.


    Please help



    Any help would be appreciated...



    i think following line is problematic,


    node.ChildNodes.Remove(node);

    you are trying do delete node from node object, self-delete is not possible :)


    instead try this


      node.ChildNodes.RemoveAll();     OR   node.ChildNodes.Clear();    

    Thanks.








    ijaz_asp



    instead try this


     node.ChildNodes.RemoveAll(); OR node.ChildNodes.Clear(); 




    same error "Collection is Read only" for node.ChildNodes.Clear();  Method Removeall(); does not exist at all



    hmm, if this is the case , try to hide the item instead of deleting it. like if the data-bound item does not fullfill your display/visible logic then get it from template object and set its visibility to none or simply set visible=false.


    thanks



    I am able to set the Visible property (e.Item.Visible =
    false;)
    for the Parent node in ItemDataBound(object
    sender,
    RepeaterItemEventArgs e) but not able to hide the
    hyperlink which is dynamically created using repeater control.


    Please help me with an example



    it may be something like this,


    var hyperlink = e.Item.findControl("ID of HyperLink") as HyperLink;

    if(hyperlink !=null)
    {
    hyperlink.visible=false; // if it does not meet your criteria .
    }

    thanks





    These hyperlinks are dynamically generated in a repeater control. Not sure of the ID.



    Hi,


    The id is you set in makeup code



    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    SiteMapNode thisMapNode = (SiteMapNode)e.Item.DataItem;
    thisMapNode.ReadOnly = false;
    if (thisMapNode.Title == "Admin")
    {
    if (Page.User.IsInRole("enterprisenet.org\\gbs idm Shift leads"))
    {
    e.Item.Visible = true;
    }
    else
    {
    e.Item.Visible = false;
    }
    }
    else
    {
    SiteMapNodeCollection siteMapCollection = thisMapNode.ChildNodes;
    foreach (SiteMapNode node in siteMapCollection)
    {
    string requestType = node.Title;
    SqlDataSource1.SelectCommand = "SELECT [Visible] FROM [IDMServicesList] where [RequestType]='" + requestType + "'";
    //SqlDataSource1.SelectParameters.Add("RequestType", requestType);
    DataView dv = (System.Data.DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
    if (dv.Count > 0)
    {
    DataRowView drv = dv[0];
    string Visible = drv["Visible"].ToString();
    if (Visible == "Hide")
    {
    Repeater thisRepeater = (Repeater)e.Item.FindControl("Repeater1"); HyperLink thisLink = (HyperLink)thisRepeater.FindControl("HyperLink2"); thisLink.Visible = false; }
    }
    }
    }
    }

    I have implemented your code but on the runtime thisLink is null. On thisLink.Visisble, I get object reference not set to instance of an object.






  24. <%# Eval("Title") %>






    • <%# Eval("Title") %>









  25. On the Repeater1 (Inside the menu Repeater) databound event, I am able to find the id of Hyperlink


    HyperLink thisLink = (HyperLink)e.Item.FindControl("HyperLink2");
    if (thisLink != null)
    {
    thisLink.Visible = false;
    }

    Not sure y your code did not work



    Hi,


    Try it like this


     NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %>

    And in code behind define the method isVisible()


    public bool isVisible() 
    {
    if (something ...)
    return true;

    else
    return false;
    }

    And refer the thread


    http://stackoverflow.com/questions/10199698/set-visible-of-a-label-from-code-behind


    http://forums.asp.net/t/1409887.aspx/1


    Hope it can help you