Hi Mohan, Check for the below code. Datagrid.Databind 'After binding the datagrid Dim item As DataGridItem Dim i as integer=0 For Each item In Datagrid.Items i+=1 item.Cells(0).Text=i 'Where item.Cells(0) is the first column in your datagrid if you have kept for serial number. Next '--------------------------------------- Or you can append the value of "i" while you are using datatable when you fill it with datareader. Regards, Raghu.
RaghuSanta
Posts
-
Serial No -
DATAGRID template column problemHi Faisal, Here i have listed some steps according to your requirement. Hope this will be helpful. 1. Modify your template column in the datagrid as below in the design/source view. 2.In the Vb code file, Create a Procedure which be called when the checkbox state is changed. Private Sub OnStatusChangedEvent(ByVal sender As Object, ByVal e As System.EventArgs) Dim cboxStatus As CheckBox Dim dGrid As DataGridItem cboxStatus= CType(sender, CheckBox) 'This will inherit the datagrid template checkbox propeties which you have clicked dGrid = CType(cboxStatus.NamingContainer, DataGridItem) 'If you need to find the text value in any datagrid column for ex. ID then Dim id as integer=dGrid.Cells(0).Text 'Here id is the first column in the datagrid for your example If cboxStatus.Checked = True Then 'Do the sql insert/update here by passing the id. End If End Sub This will be useful only when you want to update a row by changing the Checbox state in the template. Otherwise if you need to update multiple row you have to loop through all rows and write a procedure in a button click event(When you use button click event set autopostback="false" in the checkbox). Regards, Raghu -- modified at 4:54 Friday 27th April, 2007
-
string format on decimal valueHi, The format is String.Format("{0:#,###}", 50000) Regards, Raghu
-
How to Write this QueryFYI, SELECT Convert(nvarchar(11),ReceivedDate, 113) AS ReceivedDateFromClient FROM Table Regards, Raghu.
-
How to upload a folder in asp.netHi all, How to upload a folder in asp.net.
-
Need help to update excel file using oledbHi, I just found the solution. May be this could help others. Dim sConn As String Dim OleConn As OleDbConnection Dim OleCmd As OleDbCommand sConn ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\testexcel.xls;Extended Properties=""Excel 8.0;HDR=No;""" OleConn = New OleDbConnection(strConn) OleConn.Open() OleCmd = OleConn.CreateCommand() Olecmd.commandtext="UPDATE [sheet1$F1:A1] SET F1 ='6'" OleCmd.ExecuteNonQuery() OleCmd = Nothing OleConn.Close() On giving the above statement, the cell A1(first row first column) gets updated with value in the excel. Regards, Raghu.
-
Need help to update excel file using oledbHi All, How to update a cell value in a excel sheet. Ex. Need to update A1 value in excelworksheet using oledb. When tried to update I am getting error like "No value given for one or more required parameters." Raghu
-
Removing white Space.Hi, You can look into this nice article at Codeproject. Regards, Raghu
-
SMTP Setting for sending emailsIn the web.config, add a key under appsettings. The value should be the ip address of the machine which is hosting. If local machine, then put localhost. Then in your sendmail function add one more line before smtpmail.send. SmtpMail.SmtpServer = ConfigurationSettings.AppSettings("smtpServerName") SmtpMail.Send(objMail) Regards, Raghu.
-
set focus in asp.net 1.1 with vb.netIn code behind file include this code. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load setfocus(textboxid,me) End sub Private Sub setFocus(ByVal ctrl As Control, ByVal page As Page) Dim s As String = "document.getElementById('" + ctrl.ID + "').focus() " page.RegisterStartupScript("focus", s) End Sub Regards, Raghu
-
PDF to TXT/RTF/DOCYou can use Able2 Extract software to extract from pdf. Raghu
-
popup menu on right click on datagridCreate a div element and place the datagrid inside it. Then insert the below mentioned javascript(Popup menu script-Dynamicdrive.com) in the head of the page. Call this javascript from div element "oncontextmenu" //DynamicDrive.com var defaultMenuWidth="150px" //set default menu width. var linkset=new Array() //SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT linkset[0]='<a href="http://dynamicdrive.com">Dynamic Drive</a>' linkset[0]+='<hr>' //Optional Separator linkset[0]+='<a href="http://www.javascriptkit.com">JavaScript Kit</a>' linkset[0]+='<a href="http://www.codingforums.com">Coding Forums</a>' linkset[0]+='<a href="http://www.cssdrive.com">CSS Drive</a>' linkset[0]+='<a href="http://freewarejava.com">Freewarejava</a>' linkset[1]='<a href="http://msnbc.com">MSNBC</a>' linkset[1]+='<a href="http://cnn.com">CNN</a>' linkset[1]+='<a href="http://news.bbc.co.uk">BBC News</a>' linkset[1]+='<a href="http://www.washingtonpost.com">Washington Post</a>' ////No need to edit beyond here var ie5=document.all && !window.opera var ns6=document.getElementById if (ie5||ns6) document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>') function iecompattest(){ return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body } function showmenu(e, which, optWidth){ if (!document.all&&!document.getElementById) return clearhidemenu() menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu") menuobj.innerHTML=which menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth menuobj.contentwidth=menuobj.offsetWidth menuobj.contentheight=menuobj.offsetHeight eventX=ie5? event.clientX : e.clientX eventY=ie5? event.clientY : e.clientY //Find out how close the mouse is to the corner of the window var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY //if the horizontal distance isn't enough to accomodate the width of the context menu if (rightedge<menuobj.contentwidth) //move the horizontal position of the menu to the left by it's width menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px" else //position the horizontal position of the menu where the mouse was clicked menuobj.style.left=ie5? iecompattest().sc</x-turndown>