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
rohit janapally
NA
3
4.2k
I am unable to update my Details in Grid view.
Apr 29 2013 5:15 AM
Grid view.aspx:-
<table width="100%">
<tr>
<td align="right" style="width: 50%">
</td>
<td style="width: 50%">
</td>
</tr>
<tr>
<td align="right" style="width: 50%">
</td>
<td style="width: 50%">
</td>
</tr>
<tr>
<td align="right" style="width: 50%">
</td>
<td style="width: 50%">
</td>
</tr>
<tr>
<td align="right" style="width: 50%">
Camera Identity
</td>
<td style="width: 50%" align="left">
<asp:TextBox ID="txtCI" runat="server" Width="249px" OnTextChanged="txtCI_TextChanged"
AutoPostBack="True"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right" style="width: 50%">
Camera URL
</td>
<td style="width: 50%" align="left">
<asp:TextBox ID="txtCU" runat="server" Width="249px" ReadOnly="True"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right" style="width: 50%">
FTP Folder
</td>
<td style="width: 50%" align="left">
<asp:TextBox ID="txtFTP" runat="server" Width="249px" Style="margin-left: 0px" ReadOnly="True"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right" style="width: 50%">
Email ID
</td>
<td style="width: 50%" align="left">
<asp:TextBox ID="txtmail" runat="server" Width="249px"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right" style="width: 50%">
Password
</td>
<td style="width: 50%" align="left">
<asp:TextBox ID="txtpwd" runat="server" Width="249px" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right" style="width: 50%">
Contact Number
</td>
<td style="width: 50%" align="left">
<asp:TextBox ID="txtcontct" runat="server" Width="249px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 50%">
</td>
<td style="width: 50%" align="left">
<asp:ImageButton ID="imgsubmt" runat="server" ImageUrl="~/cimg/submit-button.png"
OnClick="imgsubmt_Click" />
<asp:ImageButton ID="imgclr" runat="server" ImageUrl="~/cimg/CLEAR.png" OnClick="ImageButton1_Click" />
</td>
</tr>
<tr>
<td colspan="2" style="width: 50%">
<asp:GridView ID="gvconfig" runat="server" AutoGenerateColumns="false" Width="1000px"
CellPadding="3" Height="150px" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None"
BorderWidth="1px" HorizontalAlign="Center" AutoGenerateSelectButton="True"
onselectedindexchanged="gvconfig_SelectIndexChanged"
AutoGenerateDeleteButton="True" onrowdeleting="gvconfig_RowDeleting">
<Columns>
<asp:BoundField HeaderText="Camera Identity" DataField="Camera_ID" />
<asp:BoundField HeaderText="Camera URL" DataField="Camera_url" />
<asp:BoundField HeaderText="FTP Folder" DataField="ftpfolder" />
<asp:BoundField HeaderText="Email ID" DataField="email_id" />
<asp:BoundField HeaderText="Password" DataField="password" />
<asp:BoundField HeaderText="Contact Number" DataField="contact_no" />
</Columns>
<FooterStyle BackColor="White" ForeColor="#000066" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<PagerTemplate>
<table>
<tr>
<td style="width: 50%">
<asp:PlaceHolder ID="ph" runat="server"></asp:PlaceHolder>
</td>
</tr>
</table>
</PagerTemplate>
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#007DBB" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#00547E" />
</asp:GridView>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
Grid view.CS:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using MySql.Data.MySqlClient;
public partial class Gridview : System.Web.UI.Page
{
string cloudeyes;
DataTable dt = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
cloudeyes = ConfigurationManager.ConnectionStrings["cloudeyes"].ToString();
if (!IsPostBack)
{
Bind();
gvconfig.Visible = true;
}
}
private void Bind()
{
MySqlConnection con = new MySqlConnection(cloudeyes);
con.Open();
MySqlCommand cmd = new MySqlCommand("sp_select", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
con.Close();
dt.Clear();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
gvconfig.DataSource = dt;
gvconfig.DataBind();
}
}
public void clearcontrolles()
{
txtCI.Text = "";
txtCU.Text = "";
txtFTP.Text = "";
txtmail.Text = "";
txtpwd.Text = "";
txtcontct.Text = "";
gvconfig.Visible = true;
}
protected void gvconfig_SelectIndexChanged(object sender, EventArgs e)
{
txtCI.Text=gvconfig.SelectedRow.Cells[1].Text;
txtCU.Text=gvconfig.SelectedRow.Cells[2].Text;
txtFTP.Text=gvconfig.SelectedRow.Cells[3].Text;
txtmail.Text=gvconfig.SelectedRow.Cells[4].Text;
txtpwd.Text=gvconfig.SelectedRow.Cells[5].Text;
txtcontct.Text=gvconfig.SelectedRow.Cells[6].Text;
}
protected void imgsubmt_Click(object sender, ImageClickEventArgs e)
{
MySqlConnection con = new MySqlConnection(cloudeyes);
con.Open();
MySqlCommand cmd = new MySqlCommand("sp_webcloud_config", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("scamid", MySqlDbType.VarChar).Value = txtCI.Text;
cmd.Parameters.Add("scamurl", MySqlDbType.VarChar).Value = txtCU.Text;
cmd.Parameters.Add("sftpfold", MySqlDbType.VarChar).Value = txtFTP.Text;
cmd.Parameters.Add("semailid", MySqlDbType.VarChar).Value = txtmail.Text;
cmd.Parameters.Add("spwd", MySqlDbType.VarChar).Value = txtpwd.Text;
cmd.Parameters.Add("scontct", MySqlDbType.VarChar).Value = txtcontct.Text;
cmd.ExecuteNonQuery();
Bind();
clearcontrolles();
gvconfig.Visible = true;
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
clearcontrolles();
}
protected void txtCI_TextChanged(object sender, EventArgs e)
{
string Name = txtCI.Text;
string url = Name + ".tenvis.info";
txtCU.Text = url;
string ftp = "/cctv/" + Name;
txtFTP.Text = ftp;
}
protected void gvconfig_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
// string Camers_ID = ((txtCI.Text)(gvconfig.Rows[e.RowIndex].Cells[0].Text);
//gvconfig.EditIndex = -1;
}
}
Reply
Answers (
1
)
app.config file change dynamically at runtime
Unable to Insert,update,delete the data..!!!