9/28/09

To make publish/upublish buttons



The surveys list is displayed by using the Repeater control:

<asp:Repeater ID="Repeater1" runat="server"
DataSourceID="SurveysSqlDataSource" >
          
<HeaderTemplate>
<table class='adminlist' cellspacing='1'>
<thead>
<tr>
<th style="width:5px">
Id</th>
<th>
Survey</th>
<th>
Description</th>
<th style="width:5px">
Questions</th> 
<th style="width:5px">
  Answerers
</th>                                                                                     
<th style="width:5px">
Published
</th>
 </tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr>
  <td>
<asp:HiddenField ID="surveyID" Value='<%# Eval("survey_id")%>' runat="server" />
<asp:CheckBox ID="CheckBox1" runat="server"  OnCheckedChanged="unCheckOthers"  AutoPostBack="True"/>
<td>
<%# Eval("name")%></td>
<td>
<%# Eval("description")%></td>
  <td align="center">                                   
<%# Eval("QuestionNum")%>                                       
</td>  
<td align="center">                                   
  <%# Eval("answerersNUM")%>                                       
</td>                                     
<td align="center">
                                       
<asp:ImageButton ID="IsPublishedImageButton" runat="server" ImageUrl='<%#setImageButtonImg( Eval( "IsPublished"))%>'  CommandName='<%# setCommandIsPublished( Eval( "IsPublished"))%>'  CommandArgument='<%# Eval("survey_id") %>' OnCommand='PublishThisSurvey' Enabled='<%# IsEnabled(Eval("QuestionNum")) %>'/>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>

To make the publish \ unpublish button i used imageButton control. When  you click it -the survey become published (or unpublished-depends on its status before)


<asp:ImageButton ID="IsPublishedImageButton" runat="server" ImageUrl='<%#setImageButtonImg( Eval( "IsPublished"))%>'  CommandName='<%# setCommandIsPublished( Eval( "IsPublished"))%>'  CommandArgument='<%# Eval("survey_id") %>' OnCommand='PublishThisSurvey' Enabled='<%# IsEnabled(Eval("QuestionNum")) %>'/>


It was hard work
Because i tried to found a way to pass 2 parameters  to PublishThisSurvey
function: 1-the current state(Published or not) and 2-survey Id.

And it very strange but somehow there is only one command argument avaliable . So finally i find out that i can use the "Command name" property for second argument.
May be it is a very clumsy solution...




    protected void PublishThisSurvey(object sender, CommandEventArgs e)
    {
    

        int surveyID = Convert.ToInt32(e.CommandArgument);
        int IsPublished = Convert.ToInt32(e.CommandName);
        bool bIsPublished = Convert.ToBoolean(IsPublished);

        //turn upside
        bIsPublished = (bIsPublished) ? false : true;
        clsDataAccess myclass = new clsDataAccess();
        myclass.UpdateSurveyPublished(surveyID, bIsPublished);
        Repeater1.DataBind();
    }

Getting started with docker

It is very simple to get started usig docker. All you need to do-is download the docker desktop for your system Once you get docker syste...