Тэги:
#how_to_display_database_table_in_asp.net_gridview #bind_database_table_in_gridview #table_in_asp.net_gridview #show_c#_datatable_in_asp.net_webform_gridview #asp.net_web_form_tutorial #add_select_link_button_to_gridview_with_command_argument #in_c#_asp.net_gridview #using_sample_project #using_SQL_Server_database #columns_in_asp.net_gridview #boundfield_in_gridview #how_to_connect_gridview_to_sql_database_in_asp.net #asp_gridview_database #asp.net_sql_table #CodAffectionКомментарии:
Thank for the video ... my job is still there for me bcaz of u people...
Ответить78 protected void insert()
{
XmlTextReader reader = new XmlTextReader(Server.MapPath("/XMLL/XMLFile1.xml"));
DataSet ds = new DataSet();
ds.ReadXml(reader);
DataView dv = new DataView(ds.Tables[0]);
DataTable dt = dv.Table;
dt.DefaultView.Sort = "citano DESC";
dt = dt.DefaultView.ToTable(true);
reader.Close();
GridView1.DataSource = dt;
GridView1.DataBind();
}
SqlConnection con = new SqlConnection("");
protected void btnPosalji_Click(object sender, EventArgs e)
{
SqlCommand com = new SqlCommand("INSERT INTO table values(@item1, @item2, @item3, @item4)", con);
com.Parameters.AddWithValue("@item1", tb1.Text);
com.Parameters.AddWithValue("@item2", tb2.Text);
com.Parameters.AddWithValue("@item3", tb3.Text);
com.Parameters.AddWithValue("@item4", DateTime.Now.ToShortDateString());
con.Open();
com.ExecuteNonQuery();
}
15 public void insert()
{
if (DropDownList1.SelectedIndex > -1)
{
string pathh= Server.MapPath($"~/TXT/{DropDownList1.SelectedValue}.txt");
string[] liness = File.ReadAllLines(putanja);
foreach (string line in liness)
{
if (line.StartsWith("SMER"))
{
string smer = line.Remove(0, 5);
DropDownList2.Items.Add(smer);
} }
} }
protected void Button1_Click(object sender, EventArgs e)
{
GridView1.DataSource = null;
GridView1.DataBind();
DataSet ds = new DataSet();
ds.Tables.Add(new DataTable());
ds.Tables.Add(new DataTable());
ds.Tables[0].Columns.Add("RBR", typeof(string));
ds.Tables[0].Columns.Add("Polazak", typeof(string));
ds.Tables[1].Columns.Add("RBR", typeof(string));
ds.Tables[1].Columns.Add("Polazak", typeof(string));
if (DropDownList1.SelectedIndex > -1 && DropDownList2.SelectedIndex > -1)
{
string pathh = Server.MapPath($"~/TXT/{DropDownList1.SelectedValue}.txt");
string[] liness = File.ReadAllLines(pathh);
int i = -1, j = 0;
foreach (string line in liness)
{
if (line.StartsWith("SMER"))
{
i++;
j = 0;
}
else
{
j++;
ds.Tables[i].Rows.Add(j, line);
}
}
if (DropDownList2.SelectedIndex == 0)
{
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
else if (DropDownList2.SelectedIndex == 1)
{
GridView1.DataSource = ds.Tables[1];
GridView1.DataBind();
}
}
13 protected void Page_Load(object sender, EventArgs e)
{
table.Columns.Add("1", typeof(int));
table.Columns.Add("2", typeof(string));
table.Columns.Add("3", typeof(string));
table.Columns.Add("3", typeof(string));
table.Columns.Add("4", typeof(string));
table.Columns.Add("5", typeof(string));
table.Columns.Add("6", typeof(string));
string path = Server.MapPath("~/text/people.txt");
string[] dataa = File.ReadAllLines(ppath);
foreach (string p in dataa)
{
string[] kolone = p.Split(';');
table.Rows.Add(kolone);
}
GridView1.DataSource = table;
GridView1.DataBind();
List<string> place = new List<string>();
foreach (string p in dataa)
{
string[] rows = p.Split(';');
place.Add(rows[6]);
}
DropDownList1.Items.Add(new ListItem(String.Empty, "-1"));
foreach (string m in place)
{
ListItem item = new ListItem(m);
if (!DropDownList1.Items.Contains(item))
{
DropDownList1.Items.Add(item);
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
DataTable temp = table.Copy();
for (int i = 0; i < temp.Rows.Count; i++)
{
if (!temp.Rows[i][1].ToString().Contains(TextBox1.Text) ||
!temp.Rows[i][2].ToString().Contains(TextBox2.Text) ||
!temp.Rows[i][3].ToString().Contains(TextBox3.Text) ||
!temp.Rows[i][4].ToString().Contains(TextBox4.Text) ||
!temp.Rows[i][5].ToString().Contains(TextBox5.Text) ||
!temp.Rows[i][6].ToString().Contains(DropDownList1.SelectedItem.Text))
{
temp.Rows.RemoveAt(i);
i--;
}
}
GridView1.DataSource = temp;
GridView1.DataBind();
}
Thank you so much! You helped me a lot! 🙂
Ответитьyou recommended to do the SQL class you did as a static class so i wont create a instence of the data base every function?
ОтветитьYou are my hero !!!!!!!!!!!!!!!!
🕳💙💣🤏👩👩💼👩✈💂👸👰♂🦹🏇🏃♀🧗🦁🐄🌱🌺🍂🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃🌱🌱🌱🌱🌱🌱🌱🌱🌱🌱🌱🌱🌱
thank you so much it solved my biggest problem 1.4K liker congratz
ОтветитьI need help
ОтветитьHiii
ОтветитьWhen I click the design button all columns are displaying like databound databound..... What's the error plz help me
ОтветитьThats great!, I have a doubt, how can I assign an ID to the table generated, I would like to add styles on it with JS... Thanks
ОтветитьVery helpful, nice explanation, thanks a lot
ОтветитьThanks
ОтветитьHow can I capture this value in the client side javascript?
ОтветитьThank you so much sir
ОтветитьThank you very much for sharing such excellent work
ОтветитьSir I need a help
ОтветитьThankz a alot
Ответитьnice one very helpful.
ОтветитьThank you very much! That was very helpful.
ОтветитьThis helped a lot! Thanks man
ОтветитьYou are my father! You saved my life! :)
ОтветитьThank you!
ОтветитьYou are amazing, thank you for sharing this video!!
Ответить👍👍
ОтветитьThis Post may be 3 years back but it helped me. :) Thank you
ОтветитьTHAANKS
ОтветитьThis helped a lot! Thanks man
Ответитьte amo
ОтветитьThank you so much
ОтветитьGot what i was looking for! Thanks a lot bro :)
ОтветитьThanks a lot!! from Chile
ОтветитьOne of the best Online tutorial I have ever seen. Not too great English but the message was crystal clear. Well delivered and Thank you for this.
Ответитьthank you... it helped me...
Ответитьhow a helpful tutorial, many thanks from Vietnam
Ответитьsir how to copy string connectionstring = @"?" from sql database table ?
ОтветитьGreat Tutorials :-) Tnx
ОтветитьThank you man!!!
ОтветитьVery Good, thank you, excellent video.
ОтветитьThank you very much! That was very helpful.
ОтветитьGood video , from chile
Ответить