Protected Sub GridView1_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
For rowIndex As Integer = GridView1.Rows.Count - 2 To 0 Step -1
Dim gviewRow As GridViewRow = GridView1.Rows(rowIndex)
Dim gviewPreviousRow As GridViewRow = GridView1.Rows(rowIndex + 1)
Dim cellCount As Integer = 0//replace 0 with column index
If gviewRow.Cells(cellCount).Text = gviewPreviousRow.Cells(cellCount).Text Then
If gviewPreviousRow.Cells(cellCount).RowSpan < 2 Then
gviewRow.Cells(cellCount).RowSpan = 2
Else
gviewRow.Cells(cellCount).RowSpan = gviewPreviousRow.Cells(cellCount).RowSpan + 1
End If
gviewPreviousRow.Cells(cellCount).Visible = False
End If
Next
End Sub
Wednesday, December 26, 2012
Monday, December 17, 2012
Bind DropdownList using arraylist,hashtable,array
Binding with array List(vb) :
Dim AnimalArrayList as new ArrayList()
AnimalArrayList.Add("Dog")
AnimalArrayList.Add("Cat")
AnimalArrayList.Add("Elephant")
AnimalArrayList.Add("Lion")
AnimalArrayList.Add("Cat")
MyDropDownList.DataSource = AnimalArrayList
MyDropDownList.DataBind()
Binding with Hashtable(c#) :
Dim AnimalArrayList as new ArrayList()
AnimalArrayList.Add("Dog")
AnimalArrayList.Add("Cat")
AnimalArrayList.Add("Elephant")
AnimalArrayList.Add("Lion")
AnimalArrayList.Add("Cat")
MyDropDownList.DataSource = AnimalArrayList
MyDropDownList.DataBind()
Binding with Hashtable(c#) :
Hashtable hTable = new Hashtable(); hTable.Add("1", "Hashtable Item 1"); hTable.Add("2", "Hashtable Item 2"); hTable.Add("3", "Hashtable Item 3"); hTable.Add("4", "Hashtable Item 4"); dropHashtable.DataSource = hTable; dropHashtable.DataBind();Binding with Array(c#,vb) :
int[] Hour = new int[24];
for (int i=0; i <=24, i++)
{
ddlHour.Items.add(Hour[i]);
}
Thursday, November 29, 2012
How to take backup of database using mysql command line
Taking backup from mysql command Line is quite simple .Just follow following steps and its done.
1)Open command prompt(run as administrator).
2)Move to the bin directory of mysql server.
3) Type following command
mysqldump -u root -p [your password] [database name for backup] -r ["filename"]
4)Dont forget to add double quotes for file name.
Note:If you dont specify path of file ,then it will go in default directory(Programfiles\Mysql\mysqlserver5.\bin).
1)Open command prompt(run as administrator).
2)Move to the bin directory of mysql server.
3) Type following command
mysqldump -u root -p [your password] [database name for backup] -r ["filename"]
4)Dont forget to add double quotes for file name.
Note:If you dont specify path of file ,then it will go in default directory(Programfiles\Mysql\mysqlserver5.\bin).
Monday, November 26, 2012
Ajax Autocomplete
To get autocomplete in textbox just drag a textbox to a form
Add toolkitscriptmanager.Then click on smart tag and select "Add Auto complete page method".
Now in Getcompletion list function add code for getting data from database.
<System.Web.Services.WebMethodAttribute()> <System.Web.Script.Services.ScriptMethodAttribute()>
Public Shared Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer, ByVal contextKey As String) As String()
Dim names As New ArrayList
Dim db As New dataBase
db.dbOpenConnection()
Dim query As String = "Select username from test "
db.cmd.CommandText = query
Dim dr As OdbcDataReader
dr = db.cmd.ExecuteReader
While dr.Read()
names.Add(dr("username").ToString())
End While
db.dbCloseConnection()
Return (
From m As String In names
Where m.StartsWith(prefixText, StringComparison.CurrentCultureIgnoreCase)
Select m).Take(count).ToArray()
End Function
You can add styles to autocomplete
<style>
For list shown
.AutoExtender
{
font-family: Verdana, Helvetica, sans-serif;
font-size: .8em;
font-weight: normal;
border: solid 1px #006699;
line-height: 20px;
padding: 10px;
background-color: White;
margin-left:10px;
}
.AutoExtenderList
{
border-bottom: dotted 1px #006699;
cursor: pointer;
color: Maroon;
}
.AutoExtenderHighlight
{
color: White;
background-color: #006699;
cursor: pointer;
}
</style>
Add one div above textbox to show list
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<br />
<div ID="divwidth"></div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:AutoCompleteExtender ID="TextBox1_AutoCompleteExtender" runat="server"
CompletionInterval="100" DelimiterCharacters="" Enabled="True"
MinimumPrefixLength="1" ServiceMethod="GetCompletionList" ServicePath=""
TargetControlID="TextBox1" UseContextKey="True"
CompletionListItemCssClass="AutoExtenderList"
CompletionListCssClass="AutoExtender"
CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
CompletionListElementID="divwidth"></asp:AutoCompleteExtender>
Friday, November 2, 2012
'System.Drawing.Image' converted to 'System.Drawing.Icon in Windows Form Application
Here Is a simple solution when you get this error.You get this error when you are trying to change icon at runtime .Here is a simple Solution to that.
Dim img As Image = 'Whatever your image is...
Dim bm As Bitmap = img
Dim hIcon As IntPtr = bm.GetHicon
Dim TheIcon As Icon = Icon.FromHandle(hIcon)
Wednesday, October 31, 2012
Seo From master page in asp.net
PRODUCT.ASPX
<!-- Replace lblProductTitle with the name of the variable that contains your product title. Make sure the value is set in the code behind page. --> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><%=lblProductTitle.Text%> » Test.com</title> <meta name="description" content="Get widgets: low prices and free shipping at Test.com" runat="server" id="description" />
PRODUCT.ASPX.VB
'Make sure this import statement appears at the top of the page. Imports System.Web.UI.HtmlControls 'Put this code in DataBind() or some other subroutine that runs on page load. 'Replace lblProductTitle with the variable containing your product title. description.Attributes("content") = " Get widgets: low prices and free shipping at Test.com. " & lblProductTitle.Text & "available for less."
Increase ASP.NET page timeout
Increase timeout of page by just adding following line
in system.web of web.config
<httpRuntime executionTimeout="600" /> <!-value is in secs-->
Tuesday, October 30, 2012
Maximum Request Length Exceeded ASP.NET
If you get this error Maximum request length exceeded while i was trying to upload several files, or a single big size file. As default, max file upload size is 4MB.
We can easily have a solution by not touching our asp.net c# or VB source code.
Just add a single line of code in your Web.config file, and you are done.
We can easily have a solution by not touching our asp.net c# or VB source code.
Just add a single line of code in your Web.config file, and you are done.
<configuration> <system.web> <httpRuntime maxRequestLength="32768" /> </system.web> </configuration>
Monday, September 10, 2012
Numbers Only in textbox
<SCRIPT
language=Javascript>
<!--
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which
: event.keyCode
if (charCode > 31 &&
(charCode < 48 || charCode > 57))
return false;
return true;
}
//-->
</SCRIPT>
<asp:TextBox ID="txtname" runat="server" Width="241px" BorderColor="#CCCCCC"
BorderStyle="Solid" BorderWidth="1px" CssClass="txtradius" onkeypress="return isNumberKey(event)"></asp:TextBox>
BorderStyle="Solid" BorderWidth="1px" CssClass="txtradius" onkeypress="return isNumberKey(event)"></asp:TextBox>
Sunday, September 9, 2012
Alphabets validation in Asp.net with javascript
<script type="text/javascript">
function validate(key)
{
var keycode = (key.which) ? key.which : key.keyCode;
var phn = document.getElementById('text');
//comparing pressed keycodes
if ((keycode < 65 || keycode > 90) && (keycode < 97 || keycode > 122))
{
return false;
}
}
</script>
<asp:TextBox ID="text" runat="server" onkeypress="return validate(event);"></asp:TextBox>
Please enter ID as your textbox id in function above
And this function in head section
Friday, June 22, 2012
Sending mail using gmail in .net
vb.net
Import namespace " System.Net.Mail".And add following coding on button click
Import namespace " System.Net.Mail".And add following coding on button click
Dim m As MailMessage = New MailMessage() m.To.Add("Email id of receiver") m.From = New MailAddress("Add your email it here") m.Subject = "Subject line of your mail is kept here" String Body = "Add you mail body here" m.Body = Body mail.IsBodyHtml = True Dim smtp As SmtpClient = New SmtpClient() smtp.Host = "smtp.gmail.com" smtp.Credentials = New System.Net.NetworkCredential ("your gmail id","password of gmail") smtp.EnableSsl = True smtp.Send(mail)
Wednesday, June 20, 2012
Asp.net Error Code BC30456 Method name is not a part of class
I had been working on a project.I create a class and placed that in App_code folder.This class contains a method filldata.Now i complied the project it ran successfully.But again when i compiled it it showed error
filldata is not a method of Search.
I again created object of class and intelligence showed me filldata.But when i compiled it same result was shown.This is nothing but the effect of late copy .When we build website it compiles some files and does really bother about changes in App_code.It may or may not compile class files in App_code.Soit generates compile time Error.
Solution
Just rebuild entire solution again not just Website.It will work.
If you get this error for a website published in IIS then delete all files and folders inside Microsoft.Net\Framework\v4.0.30319\Temporary ASP.NET Files\ based on framework you used for website.
If you get this error for a website published in IIS then delete all files and folders inside Microsoft.Net\Framework\v4.0.30319\Temporary ASP.NET Files\ based on framework you used for website.
Tuesday, June 12, 2012
Disable right click on your page
<script language=javascript>
var message="Function Not Allowed";
function clickIE4()
{
if (event.button==2)
{ alert(message); return false; }
}
function clickNS4(e)
{
if (document.layers||document.getElementById&&!document.all)
{
if (e.which==2||e.which==3)
{ alert(message); return false;
}
}
}
if (document.layers)
{ document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4; }
else
if (document.all&&!document.getElementById){
document.onmousedown=clickIE4; }
document.oncontextmenu=new Function("alert(message);return false")
</script>
var message="Function Not Allowed";
function clickIE4()
{
if (event.button==2)
{ alert(message); return false; }
}
function clickNS4(e)
{
if (document.layers||document.getElementById&&!document.all)
{
if (e.which==2||e.which==3)
{ alert(message); return false;
}
}
}
if (document.layers)
{ document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4; }
else
if (document.all&&!document.getElementById){
document.onmousedown=clickIE4; }
document.oncontextmenu=new Function("alert(message);return false")
</script>
Subscribe to:
Posts
(
Atom
)