Want to build the ChatGPT based Apps? Start here
Become a member
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
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
Nirmal Roy
1.7k
365
23.6k
How To Save grid view data in database like (Matrix).?
Jan 31 2017 5:00 AM
How To Save grid view data in database like (Matrix) format.
All gridview textbox dinamic name - "txtsurvey" + Pid.ToString()
here i m written code to save
for (int i = 0; i < GridView1.Columns.Count - 2; i++)
{
for (int j = 0; j < GridView1.Rows.Count - 1; j++)
{
int Pid = i + 2;
string resss = "txtsurvey" + Pid.ToString();
TextBox tb = (TextBox)this.GridView1.Rows[j].Cells[0].FindControl(resss);
Label lbl = (Label)this.GridView1.Rows[j].Cells[0].FindControl("lblclscode");
if (tb != null && lbl != null)
{
if (tb.Text != "")
{
string result = tb.Text;
int res = objbus.InsertServeydetails(lblsurvey.Text.Trim(), lbllocation.Text.Trim(), lbl.Text, tb.Text, Session["LoginName"].ToString());
if (res > 0)
{
Successdiv.Visible = true;
errordiv.Visible = false;
lblsuccess.Text = "Survey Details Successfully Save.";
}
}
}
}
}
and all save value show in page load in grid view.
here code
int x = 0;
DataTable dts1 = objbus.Findsurver(lblsurvey.Text.Trim(), Session["LoginName"].ToString());
if (dts1.Rows.Count > 0)
{
for (int i = 0; i < GridView1.Columns.Count - 2; i++)
{
for (int j = 0; j < GridView1.Rows.Count - 1; j++)
{
int Pid = i + 2;
string resss = "txtsurvey" + Pid.ToString();
TextBox box1 = (TextBox)this.GridView1.Rows[j].Cells[0].FindControl(resss);
if (box1 != null)
{
if (dts1.Rows[x]["Seuveydata"] != "")
{
box1.Text = dts1.Rows[x]["Seuveydata"].ToString();
//table.Columns.Add("SurveyDetails" + i, typeof(string));
//table.Rows.Add(new string[] { box1.Text.Trim() });
x++;
}
}
}
}
}
images above i have attached, i want to save data and retrieve it same data display.in grid view in asp.net C#
some one help me.
Attachment:
Capture.rar
Reply
Answers (
1
)
how to create wcf services for curd op using oracle db ?
how to save dynamically created HTML Control using c#