TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nethra R S
NA
310
335.3k
How do i write a method for this code
Jul 25 2011 3:28 AM
Dear friends how do i write a method for the code marked in red as it is repeating. I want to write a method and call it in place of the code given in red.. Can u`ll plzzz help
===============================
string menuType;
GblDefinition obj = new GblDefinition();
protected void Page_Load(object sender, EventArgs e)
{
menuType = Request.QueryString["type"];
if (!Page.IsPostBack)
{
if (menuType == "city")
{
lbltitle.Text = "City Details";
BoundField field = new BoundField();
field.DataField = "cityid";
field.HeaderText = "City ID";
DataControlField col = field;
GVDetails.Columns.Add(col);
field = new BoundField();
field.DataField = "cityname";
field.HeaderText = "City";
col = field;
GVDetails.Columns.Add(col);
DataSet ds1 = obj.LoadDataSet("Select * from city_master");
GVDetails.DataSource = ds1.Tables[0];
GVDetails.DataBind();
}
else if (menuType == "state")
{
lbltitle.Text = "State Details";
BoundField field = new BoundField();
field.DataField = "stateid";
field.HeaderText = "State ID";
DataControlField col = field;
GVDetails.Columns.Add(col);
field = new BoundField();
field.DataField = "statename";
field.HeaderText = "State";
col = field;
GVDetails.Columns.Add(col);
DataSet ds2 = obj.LoadDataSet("select * from state_master");
GVDetails.DataSource=ds2.Tables[0];
GVDetails.DataBind();
}
else if(menuType=="country")
{
lbltitle.Text = "Country Details";
BoundField field = new BoundField();
field.HeaderText = "Country ID";
field.DataField = "countryid";
DataControlField col = field;
GVDetails.Columns.Add(col);
field = new BoundField();
field.DataField = "countryname";
field.HeaderText = "Country";
col = field;
GVDetails.Columns.Add(col);
DataSet ds3 = obj.LoadDataSet("select * from country_master");
GVDetails.DataSource=ds3.Tables[0];
GVDetails.DataBind();
}
else if(menuType=="category")
{
lbltitle.Text = "Category Details";
BoundField field = new BoundField();
field.HeaderText = "Category ID";
field.DataField = "categoryid";
DataControlField col = field;
GVDetails.Columns.Add(col);
field = new BoundField();
field.DataField = "categoryname";
field.HeaderText = "Category";
col = field;
GVDetails.Columns.Add(col);
DataSet ds4 = obj.LoadDataSet("select * from category_master");
GVDetails.DataSource=ds4.Tables[0];
GVDetails.DataBind();
}
else if(menuType=="designation")
{
lbltitle.Text = "Desination Details";
BoundField field = new BoundField();
field.HeaderText = "Designation ID";
field.DataField = "designationid";
DataControlField col = field;
GVDetails.Columns.Add(col);
field = new BoundField();
field.HeaderText = "Designation";
field.DataField = "designation";
col = field;
GVDetails.Columns.Add(col);
DataSet ds5 = obj.LoadDataSet("select * from designation_master");
GVDetails.DataSource=ds5.Tables[0];
GVDetails.DataBind();
}
}
=================================
Reply
Answers (
4
)
Save data automatically in database
Login Form with Remember me Featuers