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

2014年7月13日 星期日

[RESOLVED] Asp.net clickable chart control


Hi all...


I am new to asp.net . I created a chart control with data binding and it has one series. Now I need the chart to be clickable which navigates to another pages by clicking each area. I found this solution,


                         Chart3.Series["Series1"].Url="EffJaEla.aspx";


But, here all the areas(If it is a column chart, all the columns are navigating to "EffJaEla.aspx" only) are navigatin to one page. I need to navigate to different pages by clicking columns. If the chart is with 4 columns, I need to navigate to 4 pages by
clicking 4 columns. Please help me...



Hi ThiTha,


Microsofts  chart control definitely does support click-through. Check below article out at 4guysfromrolla.


http://www.4guysfromrolla.com/articles/102809-1.aspx


And for more articles please have a look at the threads below


http://archive.msdn.microsoft.com/mschart/Release/ProjectReleases.aspx?ReleaseId=4418


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


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


http://www.advsofteng.com/doc/cdnetdoc/simpleclickable.htm


Hope this helps.


Thanks,


Jatin



here is the similar thread post,


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



Hi jats...


Actually I went through these links....but I couldn't find an answere...


Here is my design...


 

         BackColor="64, 64, 0" Palette="Chocolate" onload="Chart2_Load">

            

                

                  LegendText="EFFICIENCY" Palette="BrightPastel">

                 

                


            


            

            

            


            

                

                


            


        




    ConnectionString="<%$ ConnectionStrings:KPIConnectionString1 %>"

    SelectCommand="SELECT [Efficiency], [Fty] FROM [Efficiency_Summery] WHERE ([TransactionDate] = @TransactionDate) ORDER BY [Fty]">

   

    

   


  



There I bind data to the chart.....


then the chart is developped....


Assume I am in a column chart...


I have 4 columns in my chart... I need to click all these columns and navigate to 4 different pages with 4 columns...


Chart3.Series["Series1"].Url="EffJaEla.aspx";


This code navigates to one page by all 4 columns and it does not allow to use 4 urls...


I need to use 4 urls for 4 columns...


Hope you underestood this....


Please help me....



Thanks a lot...




Hi Ijas...


Actually I went through these links....but I couldn't find an answere...


Here is my design...


 

         BackColor="64, 64, 0" Palette="Chocolate" onload="Chart2_Load">

            

                

                  LegendText="EFFICIENCY" Palette="BrightPastel">

                 

                


            


            

            

            


            

                

                


            


        




    ConnectionString="<%$ ConnectionStrings:KPIConnectionString1 %>"

    SelectCommand="SELECT [Efficiency], [Fty] FROM [Efficiency_Summery] WHERE ([TransactionDate] = @TransactionDate) ORDER BY [Fty]">

   

    

   


  



There I bind data to the chart.....


then the chart is developped....


Assume I am in a column chart...


I have 4 columns in my chart... I need to click all these columns and navigate to 4 different pages with 4 columns...


Chart3.Series["Series1"].Url="EffJaEla.aspx";


This code navigates to one page by all 4 columns and it does not allow to use 4 urls...


I need to use 4 urls for 4 columns...


Hope you underestood this....


Please help me....



Thanks a lot...



Hi,


Do you refer the link
http://www.4guysfromrolla.com/articles/102809-1.aspx
? You can set the points url property in the chart control's databound event like this


Protected Sub chtCategoriesProductCount_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles chtCategoriesProductCount.DataBound
For Each point As DataPoint In chtCategoriesProductCount.Series("Categories").Points
Dim categoryId As Integer = point.YValues(1)
point.Url = String.Format("~/Demos/DrillDown/ProductsInCategory.aspx?CategoryID={0}", categoryId.ToString())
...
Next
End Sub

And refer the radchart control:


http://www.telerik.com/community/forums/aspnet-ajax/chart/create-chart-click-event.aspx


Hope it can help you


[RESOLVED] Multiline within DetailsView


How do I set a multiline option for the detailsview? I know this can be done on a textbox, but I haven’t done this within a detailsview


below is an example of a normal textbox... but it work withing a details view


 


            DataSourceID="SqlDataSource1" Text='<%# Eval("NOTES") %>'>



If you have worked detailsview with boundfield, edit the field in design mode. Convert boundfield to templatefield, after finish you will get textbox in insert / edit itemtemplate. You can change textbox property TextMode="multiline".

this is how the current textbox is created... how do i set it to TextMode?



<asp:BoundField
DataField="Notes"
HeaderText="Notes:"



/>














[RESOLVED] Bind a Checkbox to a Char database type


I have this, very common I think, problem...


In the DB there is column name ENABLED which is of type char(1), and contains two "boolean" values: 'Y' or 'N'


In a FormView I want to Bind this column in a checkbox, which should be checked when the column value is 'Y', unchecked otherwise...



Up to now, I am only able to cast it correctly for displaying the value, with something like:


Checked='<%# Eval("ENABLED").ToString() == "S" ? true:false %>' 

(or using a code-behind custom function to convert the value).


The problem is when I try to Update the value, because with this code, nothing happens! (the ENABLED parameter isn't passed to the Updating function!)


And if in the above code I change Eval to Bind("ENABLED") I get this error:


Compiler Error Message: CS0103: The name 'Bind' does not exist in the current context



How can I resolve this?




Use bit field instead, you will simply Checked='<%# Eval ("ENABLED") %>' use boolean parameter type, if you want to display it as y/n use select case [enabled] when true then 'y' else 'n'

You, are right, I am calling for trouble...


But I can't change the DB column datatype, because I don't have the permission (and besides the DB is queried by other applications)



Get checkbox using updating event, then set sqldatasource1.updatepatameters("enabled").DefaultValue ="y" based checked value.

[RESOLVED] Asp.net clickable chart control


Hi all...


I am new to asp.net . I created a chart control with data binding and it has one series. Now I need the chart to be clickable which navigates to another pages by clicking each area. I found this solution,


                         Chart3.Series["Series1"].Url="EffJaEla.aspx";


But, here all the areas(If it is a column chart, all the columns are navigating to "EffJaEla.aspx" only) are navigatin to one page. I need to navigate to different pages by clicking columns. If the chart is with 4 columns, I need to navigate to 4 pages by
clicking 4 columns. Please help me...



Hi ThiTha,


Microsofts  chart control definitely does support click-through. Check below article out at 4guysfromrolla.


http://www.4guysfromrolla.com/articles/102809-1.aspx


And for more articles please have a look at the threads below


http://archive.msdn.microsoft.com/mschart/Release/ProjectReleases.aspx?ReleaseId=4418


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


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


http://www.advsofteng.com/doc/cdnetdoc/simpleclickable.htm


Hope this helps.


Thanks,


Jatin



here is the similar thread post,


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



Hi jats...


Actually I went through these links....but I couldn't find an answere...


Here is my design...


 

         BackColor="64, 64, 0" Palette="Chocolate" onload="Chart2_Load">

            

                

                  LegendText="EFFICIENCY" Palette="BrightPastel">

                 

                


            


            

            

            


            

                

                


            


        




    ConnectionString="<%$ ConnectionStrings:KPIConnectionString1 %>"

    SelectCommand="SELECT [Efficiency], [Fty] FROM [Efficiency_Summery] WHERE ([TransactionDate] = @TransactionDate) ORDER BY [Fty]">

   

    

   


  



There I bind data to the chart.....


then the chart is developped....


Assume I am in a column chart...


I have 4 columns in my chart... I need to click all these columns and navigate to 4 different pages with 4 columns...


Chart3.Series["Series1"].Url="EffJaEla.aspx";


This code navigates to one page by all 4 columns and it does not allow to use 4 urls...


I need to use 4 urls for 4 columns...


Hope you underestood this....


Please help me....



Thanks a lot...




Hi Ijas...


Actually I went through these links....but I couldn't find an answere...


Here is my design...


 

         BackColor="64, 64, 0" Palette="Chocolate" onload="Chart2_Load">

            

                

                  LegendText="EFFICIENCY" Palette="BrightPastel">

                 

                


            


            

            

            


            

                

                


            


        




    ConnectionString="<%$ ConnectionStrings:KPIConnectionString1 %>"

    SelectCommand="SELECT [Efficiency], [Fty] FROM [Efficiency_Summery] WHERE ([TransactionDate] = @TransactionDate) ORDER BY [Fty]">

   

    

   


  



There I bind data to the chart.....


then the chart is developped....


Assume I am in a column chart...


I have 4 columns in my chart... I need to click all these columns and navigate to 4 different pages with 4 columns...


Chart3.Series["Series1"].Url="EffJaEla.aspx";


This code navigates to one page by all 4 columns and it does not allow to use 4 urls...


I need to use 4 urls for 4 columns...


Hope you underestood this....


Please help me....



Thanks a lot...



Hi,


Do you refer the link
http://www.4guysfromrolla.com/articles/102809-1.aspx
? You can set the points url property in the chart control's databound event like this


Protected Sub chtCategoriesProductCount_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles chtCategoriesProductCount.DataBound
For Each point As DataPoint In chtCategoriesProductCount.Series("Categories").Points
Dim categoryId As Integer = point.YValues(1)
point.Url = String.Format("~/Demos/DrillDown/ProductsInCategory.aspx?CategoryID={0}", categoryId.ToString())
...
Next
End Sub

And refer the radchart control:


http://www.telerik.com/community/forums/aspnet-ajax/chart/create-chart-click-event.aspx


Hope it can help you


[RESOLVED] Multiline within DetailsView


How do I set a multiline option for the detailsview? I know this can be done on a textbox, but I haven’t done this within a detailsview


below is an example of a normal textbox... but it work withing a details view


 


            DataSourceID="SqlDataSource1" Text='<%# Eval("NOTES") %>'>



If you have worked detailsview with boundfield, edit the field in design mode. Convert boundfield to templatefield, after finish you will get textbox in insert / edit itemtemplate. You can change textbox property TextMode="multiline".

this is how the current textbox is created... how do i set it to TextMode?



<asp:BoundField
DataField="Notes"
HeaderText="Notes:"



/>














[RESOLVED] Bind a Checkbox to a Char database type


I have this, very common I think, problem...


In the DB there is column name ENABLED which is of type char(1), and contains two "boolean" values: 'Y' or 'N'


In a FormView I want to Bind this column in a checkbox, which should be checked when the column value is 'Y', unchecked otherwise...



Up to now, I am only able to cast it correctly for displaying the value, with something like:


Checked='<%# Eval("ENABLED").ToString() == "S" ? true:false %>' 

(or using a code-behind custom function to convert the value).


The problem is when I try to Update the value, because with this code, nothing happens! (the ENABLED parameter isn't passed to the Updating function!)


And if in the above code I change Eval to Bind("ENABLED") I get this error:


Compiler Error Message: CS0103: The name 'Bind' does not exist in the current context



How can I resolve this?




Use bit field instead, you will simply Checked='<%# Eval ("ENABLED") %>' use boolean parameter type, if you want to display it as y/n use select case [enabled] when true then 'y' else 'n'

You, are right, I am calling for trouble...


But I can't change the DB column datatype, because I don't have the permission (and besides the DB is queried by other applications)



Get checkbox using updating event, then set sqldatasource1.updatepatameters("enabled").DefaultValue ="y" based checked value.

[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





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






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










  • 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.






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






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









  • 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





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






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










  • 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.






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






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









  • 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





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






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










  • 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.






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






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









  • 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





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






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










  • 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.






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






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









  • 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





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






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










  • 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.






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






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









  • 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