Convert int to Months and display in gridview

Posted by Satyapriyanayak under ASP.NET category on | Points: 40 | Views : 965
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication18._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head runat="server">
<title>Untitled Page</title>
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<asp:GridView ID="GridView1" runat="server">

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace WebApplication18
public partial class _Default : System.Web.UI.Page
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string str;
SqlCommand com;
SqlDataAdapter sqlda;
DataSet ds;

protected void Button1_Click(object sender, EventArgs e)
SqlConnection con = new SqlConnection(strConnString);
str = "SELECT DateName(mm,DATEADD(mm,MonthNumber,-1)) as [MonthName]FROM t1 where MonthNumber ='" + TextBox1.Text + "' and MonthNumber <= 12";
com = new SqlCommand(str, con);
sqlda = new SqlDataAdapter(com);
ds = new DataSet();
sqlda.Fill(ds, "t1");
GridView1.DataMember = "t1";
GridView1.DataSource = ds;

Comments or Responses

Login to post response