Archive for October, 2007

gridview events

October 25, 2007

 Maintain validations in Gridview

      <Columns>

<asp:TemplateField HeaderText=”Name” > 

<EditItemTemplate> 

    <asp:TextBox  ID=”txtName” runat=”server” Text=’<%# Bind(“Name”) %‘></asp:TextBox>    

<asp:RequiredFieldValidator ID=”RequiredFieldValidator1″ runat=”server”   ControlToValidate=”txtName”  ErrorMessage=”enter name.”                                                                                                                SetFocusOnError=”True” >*   </asp:RequiredFieldValidator>   </EditItemTemplate>      <ItemTemplate>       <asp:Label ID=”Label1″ runat=”server” Text=’<%# Bind(“Name”) %>‘></asp:Label>      </ItemTemplate> </asp:TemplateField>  <asp:BoundField DataField=”no” HeaderText=”no” />

   </columns>

                                             To retrieve that grid view values 

                                           TextBox txtAccountName = (TextBox)gridview.Rows[e.RowIndex].FindControl(“txtName”);             TextBox no = (TextBox)grideview.Rows[e.RowIndex].Cells[4].Controls[0];   

                           To call a java script function to display the confirm messages.

 <Columns>     <asp:TemplateField >     <ItemTemplate>     <asp:LinkButton  ID=”lbDelete” Text=”Delete” runat=”server”           OnClientClick=”return confirm(‘Are you sure you want to delete record ?’);”                                        CommandName=”Delete” CssClass=”labelText”   CausesValidation=”false”  />                        </ItemTemplate>  </asp:TemplateField>

</Columns>

  To retrieve a value from grid view by using data keys. int ID = Convert.ToInt32(Gridview.DataKeys[e.RowIndex].Value); 

Grid view row editing.

 Gridview.EditIndex = e.NewEditIndex; 

Grid view page index changing. 

 gridview.PageIndex = e.NewPageIndex;    

If I click edit button in grid view after that I click on submit or any other button.It performs some operations. I don’t want do operations when I click on edit button. if (GVAccounts.EditIndex == -1){} 

Consuming web service from VBScript file

October 25, 2007

Hi All,

For our current project, the requirement was to call a web service (Web service internally will do some task) on a particular time interval say hourly, daily, monthly etc…

The easy solution we adopted is consuming this web service in VBScript file and schedule this file in the MS-Scheduler. The VBScript looks like

 Set oServerXML = CreateObject(“Msxml2.ServerXMLHTTP”) oServerXML.Open GET”,”http://chm18/purgeservice/purgeservice.asmx/DeleteArchiveFolder1″, FalseoServerXML.setRequestHeader “Content-Type”,”application/x-www-form-urlencoded” oServerXML.sendSet oServerXML = nothing  

Just copy the above code in a VBScript file and schedule this file in a MS-Scheduler. While executing this file if u not yet get the result means then try to execute the web service from .net application using the HTTPWebRequest method. if this is executing without errors means then the VBScript file executes correctly. Note: While executing the web service using HTTPWebRequest method if u got the “The remote server returned an error: (500) Internal Server Error” means then go and add the following code snippet in the web.config file of the web service                   

     <webServices>
           <protocols>
                                         <add name=”HttpGet”/>
                                          <add name=”HttpPost”/>
         </protocols>
</webServices>

 That’s all the web service will works fine…. 

Regards

DotnetRaja