<table class="style1">
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td>
<asp:Label ID="Lbl4" runat="server" Text="name1"></asp:Label>
</td>
<td>
<asp:TextBox ID="Txt1" runat="server" Visible="true"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td>
<br />
name2</td>
<td>
<br />
<asp:TextBox ID="Txt2" runat="server" Visible="true"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="Subbtn1" runat="server" onclick="Subbtn1_Click" Text="Submit" />
</td>
</tr>
</table>
protected void Subbtn1_Click(object sender, EventArgs e)
{
SPSite site = SPContext.Current.Site;
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true;
SPList list = web.Lists["mylist"];
SPListItemCollection itemcoll = list.Items;
SPListItem item = itemcoll.Add();
item["employenames"] = Txt1.Text;
item["eno"] = Txt2.Text;
item.Update();
}
Get items from list
protected void Subbtn1_Click(object sender, EventArgs e)
{
SPSite site = SPContext.Current.Site;
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true;
SPList list = web.Lists["mylist"];
}
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td>
<asp:Label ID="Lbl4" runat="server" Text="name1"></asp:Label>
</td>
<td>
<asp:TextBox ID="Txt1" runat="server" Visible="true"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td>
<br />
name2</td>
<td>
<br />
<asp:TextBox ID="Txt2" runat="server" Visible="true"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="Subbtn1" runat="server" onclick="Subbtn1_Click" Text="Submit" />
</td>
</tr>
</table>
protected void Subbtn1_Click(object sender, EventArgs e)
{
SPSite site = SPContext.Current.Site;
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true;
SPList list = web.Lists["mylist"];
SPListItemCollection itemcoll = list.Items;
SPListItem item = itemcoll.Add();
item["employenames"] = Txt1.Text;
item["eno"] = Txt2.Text;
item.Update();
}
Get items from list
protected void Subbtn1_Click(object sender, EventArgs e)
{
SPSite site = SPContext.Current.Site;
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true;
SPList list = web.Lists["mylist"];
SPQuery myquery =
new
SPQuery();
myquery.Query =
"insert your query here"
;
SPListItemCollection items = list.GetItems(myquery);
foreach
(SPListItem item
in
items)
{
if
(item !=
null
)
{
}
}
}
No comments:
Post a Comment